define ss varchar(255); define tt char(1); define result decimal(20,0); define i integer;
let ss = lower(s1); let ss = trim( both from ss ); if ( substr( ss, 1,1 ) = '0' and substr( ss,2,1 ) ='x' ) then let ss = substr( ss,3 ); end if
let result = 0;
for i =1 to length ( ss ) let tt = substr( ss,i,1); let result = result * 16 + decode( tt, 'a',10,'b',11, 'c',12,'d',13, 'e',14,'f',15, tt+0); end for return result end procedure;