lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Merick wrote:
> Thanks guys, but neither of these is working for me. With both pack
> and struct, if I try to write something the numbers that FreeBASIC
> reads from the file are wrong. For instance, if I use a =
> struct.pack("BHIL",1,2,3,4) and write it to a file, the numbers that
> are returned from FB's "get" function are either (1, 2, 1027, 0) or
> (1, 768, 4, 0) depending on whether I try to read each number one at
> a time, or all at once as a user defined type

Without a dump of the actual data, the problem can come from either
struct of FB. Try:

a = struct.pack("BHIL",1,2,3,4)
print(table.concat({string.byte(a,1,#a)}," "))

On my 32bits WinXP it gives:

1 2 0 3 0 0 0 4 0 0 0

which is the expected result.