Parse to number error
Posted: Sat Aug 04, 2018 10:46 pm
I am trying to create a LCB handler that converts a number from base 16 to base 10, however, it is erroring out at the line where I parse to a number...
error: Parsing error: syntax error
parse tChar as Number into tNum
^
5:36 PM: Error: failed to compile module
below is my actual code:
error: Parsing error: syntax error
parse tChar as Number into tNum
^
5:36 PM: Error: failed to compile module
below is my actual code:
Code: Select all
public handler hexToDec(in pText as String)
variable tChar as optional String
variable tNum as optional Number
variable tSum as Number
variable tCount as Number
variable tHex as Number
put the number of chars in pText into tCount
repeat for each char tChar in pText
subtract 1 from tCount
if tChar is "A" then
put "10" into tChar
else if tChar is "B" then
put "11" into tChar
else if tChar is "C" then
put "12" into tChar
else if tChar is "D" then
put "13" into tChar
else if tChar is "E" then
put "14" into tChar
else if tChar is "F" then
put "15" into tChar
end if
parse tChar as Number into tNum
add (tNum * (16^tCount)) to tSum
end repeat
return tSum
end handler