Use to-issue instead of to-hex.
(to-hex doesn't like strings):
>> to-hex "1e"
** Script Error: to-hex expected value argument of type: integer
** Near: to-hex "1e"
>> to-issue "1e"
== #1e
>> to-integer to-issue "1e"
== 30
>> to-integer to-issue to-hex 30
== 30
Hence,
hex-string-to-integer: func [
"Converts a hexadecimal string of two characters to an integer"
string [string!] "string you want to convert"
][
to-integer to-issue string
]
example:
>> hex-string-to-integer "1f"
== 31
It's too little for a function, just put a comment instead,
unless you want to check your inputs.
Anton.
> Need function which take a two char string input and returns the
> integer value. The problem here is I can't work out how to tell Rebol
> that a string variable can be thought of as hex.
>
> Here's my hacky solution;
>
> StringToHex: func [
> stringin [string!]
> ][
> do rejoin["result: to-integer #{"stringin"}"]
> result
> ]
> Mat.
--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.