|
Post by alexfish on Dec 5, 2019 0:27:59 GMT 1
Hi All
whilst working on html2text I needed a function to continually extract sequential string numbers to real integers or long
hence found strtol , thing this may be of help to others
PROTO strol
LOCAL str = "202 2003" TYPE STRING LOCAL hexnumb ="0xff" TYPE STRING LOCAL binary = "00000001 11111111" TYPE STRING LOCAL res TYPE long LOCAL pEnd TYPE STRING 'hex string res = strtol(binary,NULL,0) 'binary string Base(2) To DECIMAL can try others res = strtol(hexnumb,NULL,0)
PRINT res
' strtol postion of number at first and second res = strtol(binary,&pEnd,2) PRINT res res = strtol(pEnd,&pEnd,2)
PRINT res
' strtol postion of number at first and second
res = strtol (str,&pEnd,10)
PRINT res res = strtol (pEnd,&pEnd,10)
PRINT res
BR Alex
|
|