On Wednesday, August 6, 2003, at 03:37 PM, David Beck wrote:
function ReadUInt16 filePath, count
if the platform is "Win32" then
read from file filePath for (count * 2)
Consider URL binfile:
put it into rawData
put "" into finalResult
put "" into curNum
repeat while rawData is not empty
put binaryDecode( "n", char 1 to 2 of rawData, curNum ) into dummy
-- we need to give the number its sign ourselves, since
-- the 'n' flag always reads unsigned data on Windows.
if curNum < 0 then put 32768 + ( curNum + 32768 ) into curNum
Typo? This can't be right.
put curNum & comma after finalResult
This is fast. However, it converts numbers to strings. You might want to consider using an array.
delete char 1 to 2 of rawData
This is slow for long strings. There is probably a faster way using 'char i to i+1 ...', but maybe not.
end repeat
delete the last char of finalResult
else
read from file filePath for count uint2
put it into finalResult
Did you edit out the non-Windows script?
end if
return finalResult end ReadUInt16
This way you avoid doing a 1-byte file read for every number, which would
slow things down a lot.
I also have cross platform functions to read/write
big endian unsigned 2-byte ints and unsigned 4-byte ints. If anybody would
like them, drop me a note.
Cool. That is the way to do it. Will they still work when Windows is fixed?
Anybody willing to check sign/unsigned on linux?
Dar Scott
************************************************************************ ****
Dar Scott Consulting http://www.swcp.com/dsc/ Programming Services
************************************************************************ ****
_______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
