-
FlexPro
- Auf einen Blick
- Features & Optionen
- Einsatzgebiete
- Alle Vorteile
- Neu in FlexPro 2021
- FlexPro gratis testen
- FlexPro View OEM Freeware
- Kaufberatung
- Login
- Language
- +49 6894 929600
- infoweisang.com
- Google Maps
- Produkte
- News
- Support
- Unternehmen
- Jobs
- Kontakt
- Login
- Language
- +49 6894 929600
- infoweisang.com
- Google Maps
Hex to Dez conversion
- Dieses Thema hat 6 Antworten sowie 2 Teilnehmer und wurde zuletzt vor vor 18 Jahren, 5 Monaten von peter.zeyher@mechatronic.de aktualisiert.
-
AutorBeiträge
-
Juli 17, 2006 um 10:20 pm Uhr #12509peter.zeyher@mechatronic.deMitglied
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
Juli 17, 2006 um 10:20 pm Uhr #8172peter.zeyher@mechatronic.deMitgliedI 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
Juli 17, 2006 um 11:15 pm Uhr #8815Bernhard KantzTeilnehmerTry 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
Juli 18, 2006 um 12:17 am Uhr #8816peter.zeyher@mechatronic.deMitgliedThanks!
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
Juli 18, 2006 um 12:46 am Uhr #8817Bernhard KantzTeilnehmerUse 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)Juli 18, 2006 um 1:36 am Uhr #8818peter.zeyher@mechatronic.deMitgliedThanks 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
Juli 18, 2006 um 1:59 am Uhr #8819Bernhard KantzTeilnehmerHere 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.
-
AutorBeiträge
- Du musst angemeldet sein, um auf dieses Thema antworten zu können.