-
FlexPro
- At a Glance
- Features & Options
- Applications
- All Advantages
- What’s New in FlexPro 2021
- Try FlexPro For Free
- FlexPro View OEM Freeware
- Buying Guide
- Login
- Language
-
-
-
- +49 6894 929600
- infoweisang.com
- Google Maps
- Products
- News
- Support
- Company
- Contact
- Login
- Language
-
-
-
- +49 6894 929600
- infoweisang.com
- Google Maps
Hex to Dez conversion
- This topic has 6 replies, 2 voices, and was last updated 18 years, 8 months ago by
peter.zeyher@mechatronic.de.
-
AuthorPosts
-
July 17, 2006 at 10:20 pm #12509
I am trying to convert data in hex format to dez numbers using the following script. It won’t run because of a syntax error (behind the first else). The numbers are in the following format: 0xFFFF
Script is:
for i = 6 to 3 do
b = stringmid(test,i,1)
if (b = ‘F’) then (b=15) else
if (b = ‘E’) then b=14 else
if (b = ‘D’) then b = 13 else
if (b= ‘C’) then b =12 else
if (b = ‘B’) then b = 11 else
if (b= ‘A’) then b =10
end
end
end
end
end
end
D = D + (b * 16^(6-i))
end
return DThanks already
Peter
July 17, 2006 at 10:20 pm #8172I am trying to convert data in hex format to dez numbers using the following script. It won’t run because of a syntax error (behind the first else). The numbers are in the following format: 0xFFFF
Script is:
for i = 6 to 3 do
b = stringmid(test,i,1)
if (b = ‘F’) then (b=15) else
if (b = ‘E’) then b=14 else
if (b = ‘D’) then b = 13 else
if (b= ‘C’) then b =12 else
if (b = ‘B’) then b = 11 else
if (b= ‘A’) then b =10
end
end
end
end
end
end
D = D + (b * 16^(6-i))
end
return DThanks already
Peter
July 17, 2006 at 11:15 pm #8815Bernhard Kantz
ParticipantTry this:
Dim i, b, D D = 0 For i = 3 to 6 do b = stringmid(test,i,1) if (b == "F") then (b=15) elseif (b == "E") then b=14 elseif (b == "D") then b = 13 elseif (b== "C") then b = 12 elseif (b == "B") then b = 11 elseif (b == "A") then b = 10 end D = D + (b * 16^(6-i)) end return D
July 18, 2006 at 12:17 am #8816Thanks!
The next problem is that I have a “Datenreihe mit … Zeichenketten” called ‘Test’ that I want to convert. The function Stringmid(Test,i,1) gives me the following error message: “Das erst Argument der Funktion Stringmid() hat falsche Datenstruktur. Das Argument muss ein Zeichenketten Einzelwert sein.”
How can I get the function to convert all the values ?
Thanks
Peter
July 18, 2006 at 12:46 am #8817Bernhard Kantz
ParticipantUse the index operator to get a scalar value from a data set.
Example:
Dim i, result result = 0 # NumberOfRows(Test) For Each Row i In Test Do result = HexToDez(Test) End result
The HexToDez is a FPScript formula which converts Hex values into decimal values. This formula uses the Arguments statement.
See also
FlexPro Online Help (F1)July 18, 2006 at 1:36 am #8818Thanks a lot! This works for me now.
I have to use slightly different function (maybe because I am using FlexPro 6?):
Dim i,D, result
result = 0 # Numberofvalues(Weg)
For Each value i In Weg Do
D = HextoDez(Weg)
If D>60000 then D=D-65536
end
D=D/500
result = D
End
resultand I had to do my own hextodez function which looks like this:
arguments h
Dim D,iD = 0
For i = 2 to 5 dob = stringmid(h,i,1)
if (b == “F”) then (b=15)
elseif (b == “E”) then b=14
elseif (b == “D”) then b = 13
elseif (b == “C”) then b = 12
elseif (b == “B”) then b = 11
elseif (b == “A”) then b = 10
end
D = D + (b * 16^(5-i))
endThe only problem is that this is quite slow (with 130000 numbers). Is there any possibility to speed the function up, or at least to have it calculate everything again as soon as I use the function in a diagram etc. ?
Thanks
Peter
July 18, 2006 at 1:59 am #8819Bernhard Kantz
ParticipantHere is an alternative FPScript-Function:
dim chars, idx dim a, res, i, n chars = "0123456789ABCDEF" a = "2FFF" res = 0L n = StringLength(a) - 1 For i = 0 to n Do idx = StringFind(chars, StringMid(a, i, 1)) if idx < 0 then return 0 End res = res * 16 + idx End res
You can convert your FPScript formula into a dataset. Alternatively you could use VBA with FlexPro Professional to convert your values.
-
AuthorPosts
- You must be logged in to reply to this topic.
You are currently viewing a placeholder content from Facebook. To access the actual content, click the button below. Please note that doing so will share data with third-party providers.
More InformationYou need to load content from reCAPTCHA to submit the form. Please note that doing so will share data with third-party providers.
More InformationYou are currently viewing a placeholder content from Instagram. To access the actual content, click the button below. Please note that doing so will share data with third-party providers.
More InformationYou are currently viewing a placeholder content from X. To access the actual content, click the button below. Please note that doing so will share data with third-party providers.
More Information