I've got a string that's in hexadecimal. I need to convert this to an integer. I don't mind writing the function, but is there one already available?
I basically want something that can spit back '10' from this:
'cept that doesn't work.
<font class="small">Code:</font><hr /><pre>
[ ] INTEGER i = 0xa
[ ] Print(Val(Str(i)))
Here first we need to store the value into a INTEGER type then you convert into a string because Val() functions accepts only string type.
I hope this helps you.
Try and fail, but don't fail to try
Good to know this!
I can't do that. I'm starting with a string. It's being read from somewhere else.
Use TonyM's routine, intHex2Dec.
How do you append an int to a string?
writeToFileRes("Number of tests performed in test case - " + testCounter)
testCounter is an int and I need to append to a string
writeToFileRes("Number of tests performed in test case - " + Str(testCounter))
No problem then you can assign it to an integer, then use Str() function to convert it into string then apply val() function.
Here you can only obtain the exact result if and only if the variable is integer string, not a normal string.If you don't do that you may get wrog result like "0".