Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Dumb problem

From: anton:lexicon at: 24-Apr-2002 13:26

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.