   10 input "enter two digit hex number" , a$
   11 if len( a$ ) = 0 then 999 
   15 if len( a$ ) <> 2 then print "two digits required" : goto 10
   20 c$ = left$( a$ , 1 ) 
   30 gosub 100
   40 n = x
   50 c$ = mid$( a$ , 2 , 1 ) 
   60 gosub 100
   70 print "result = " , n * 16 + x
   80 goto 10
  100 if '0' <= c$ and c$ <= '9' then x = ascii( c$ ) - ascii( "0" ) : return 
  110 if 'a' <= c$ and c$ <= 'f' then x = ascii( c$ ) - ascii( "a" ) + 10 : return 
  120 print "bad hex digit '" ;c$; "' assuming zero" : x = 0 : return 
  999 end
