How to convert text to hexadecimal in Nav 2005

malintus
Member Posts: 32
Hi,
I need to export data by XMLPort but as a hexadecimal values. Since Nav 2009R2 is possible by DotNet but in nav 5.0 is not possible to use it, I think.
Do anyone have some ideas how text could be converted to hex in this ver. of Navision?
Regards
Malintus
I need to export data by XMLPort but as a hexadecimal values. Since Nav 2009R2 is possible by DotNet but in nav 5.0 is not possible to use it, I think.
Do anyone have some ideas how text could be converted to hex in this ver. of Navision?
Regards
Malintus
0
Best Answer
-
OnRun() MESSAGE('0x%1',ConvertBase16('Hogan')); LOCAL ConvertBase16(theInput : Text[512]) theOutput : Text[1024] FOR aIndex := 1 TO STRLEN(theInput) DO BEGIN aInt := theInput[aIndex]; aLeft := ROUND(aInt / 16,1,'<'); aRight := aInt MOD 16; theOutput += HexValue(aLeft) + HexValue(aRight); END; LOCAL HexValue(theValue : Integer) : Text[1] CASE theValue OF 0..9: EXIT(FORMAT(theValue)); 10: EXIT('A'); 11: EXIT('B'); 12: EXIT('C'); 13: EXIT('D'); 14: EXIT('E'); 15: EXIT('F'); END;
6
Answers
-
I think you mean BASE64. Which is commonly used to embed binary data in XML-files.
Edit: Found this post https://forum.mibuso.com/discussion/5735/post-of-code-base64-encoding-and-decoding0 -
Hex is another way of saying Base16, but never done it or seen it being done in NAV0
-
@Duikmeester No, I mean BASE16. Generally I want to achieve the same thing what I can achieve from t-sql query. I mean:
select distinct convert (varbinary, 'Hogan') as Employee
I get the following
Employee = 0x486F67616E0 -
In that case, maybe System.Data.SqlClient as automation could be the solution0
-
OnRun() MESSAGE('0x%1',ConvertBase16('Hogan')); LOCAL ConvertBase16(theInput : Text[512]) theOutput : Text[1024] FOR aIndex := 1 TO STRLEN(theInput) DO BEGIN aInt := theInput[aIndex]; aLeft := ROUND(aInt / 16,1,'<'); aRight := aInt MOD 16; theOutput += HexValue(aLeft) + HexValue(aRight); END; LOCAL HexValue(theValue : Integer) : Text[1] CASE theValue OF 0..9: EXIT(FORMAT(theValue)); 10: EXIT('A'); 11: EXIT('B'); 12: EXIT('C'); 13: EXIT('D'); 14: EXIT('E'); 15: EXIT('F'); END;
6 -
@Duikmeester Thanks, it's working perfectly and it was much more simpler that I thought.
I tried to use ADO and SQL select command to replace it but I had problems with receive data from my query. Your script working perfectly. Again thank you a lot.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions