Hello,
I need to create a binary file inserting a list of numbers 1 2 3 4 5 6 .. is there functions to do it? I have tryed Fopen() Fwrite() but also if I ahve converted number to exadeciaml the result is always in text format.
This is may code, any idea?
Thanks
Luigi
I need to create a binary file inserting a list of numbers 1 2 3 4 5 6 .. is there functions to do it? I have tryed Fopen() Fwrite() but also if I ahve converted number to exadeciaml the result is always in text format.
This is may code, any idea?
Thanks
Luigi
Code:
lnfile=FCREATE('test.bin')
FOR a=1 TO 15
=FWRITE(lnfile,dec2hex(a))
endfor
FCLOSE(lnfile)
PROC Dec2Hex(nDec)
*
LOCAL nResto,cHex,nDig
nResto=nDec
cHex=""
DO WHILE nResto > 15
nDig=MOD(nResto,16)
IF nDig < 10
cHex=STR(nDig,1) + cHex
ELSE
cHex=CHR(55+nDig) + cHex
ENDIF
nResto=INT(nResto / 16)
ENDDO
nDig=nResto
IF nDig < 10
cHex=STR(nDig,1) + cHex
ELSE
cHex=CHR(55+nDig) + cHex
ENDIF
IF LEN(chex)=1
cHex='0'+Chex
ENDIF
RETURN cHex
*
ENDPROC