PDA

View Full Version : WriteNumber()



eppo
05-28-2008, 09:13 AM
Hi,

I'm having some problems writing floats (numbers) to binary files. After opening a file in "wb" mode, writing something with WriteNumber() and then reopening the file in "rb", I'm not reading the same number as written. Usually just "0" (in a hex-editor as well). Also, WriteNumber() returns 1 byte written, which seems incorrect to me...

faulknermano
05-29-2008, 10:51 PM
writeNumber(number)
In ASCII mode, the writeNumber(number) function will write a value into the text file as a floating-point number in character format. In Binary mode, a string is written to the file. The value returned is the number of bytes written to the file.


are you sure you intend to write floats as strings? or do you want to write floats? if so, try using writeDouble() / writeShort().

LightFreeze
05-31-2008, 07:19 AM
Its a bug, should be fixed in 9.5

my Lscript ref shows


writeNumber(number)
In ASCII mode, the writeNumber(number) function will write a
value into the text file as a floating-point number in character
format. In Binary mode, a single binary value of size double is
written to the file. The value returned is the number of bytes
written to the file.

eppo
05-31-2008, 08:45 AM
Okay thank you.
I've solved it by writing both the real part and the remainder as seperate integers.

eppo
05-31-2008, 08:47 AM
I didn't know writeDouble() existed, I'll try that too.

faulknermano
06-01-2008, 09:20 PM
Its a bug, should be fixed in 9.5

my Lscript ref shows

good grief, you're right... i was referring to dodgy's docs at that time. i guess it was a typo. thanks for the correction.