\ fieldutils

needs fields

: ud>s  ( d. -- n )    drop ;   inline

\ Parse the string. Return the 16-bit
\ number and a true flag if the 
\ conversion was successful. If an
\ illegal character was encountered,
\ just return a false flag.
: string>u  ( str len -- u true | false )
    0. 2swap        ( d. str len )
    >number      ( d.' str' len' )
    \ if len' is zero, all chars converted
    if
        drop 2drop false
    else
        drop   ud>s   true
    then ;

create ubuf 6 allot
: field>uhex 
    ( fieldID -- u true | false )
    hex
    ubuf swap field>string    ( len )
    ?dup if
        ubuf swap                ( str len )
        string>u                   ( u true | false )
    else
        ( )
        \ no chars in field, so return 0
        0
    then ;



