lua-users home
lua-l archive

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


Check out the string.char and string.byte functions.

http://www.lua.org/manual/5.1/manual.html#pdf-string.byte

-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br on behalf of Stockdale, Daire, SOE
Sent: Thu 5/11/2006 5:21 AM
To: lua@bazar2.conectiva.com.br
Subject: Writing binary data
 
Hello

Is there any way to write to file the binary representation of a
lua_Number without using a custom module? I'd like the following to
work:

local myNumbers = { 0.0, 1.0, 2.0, 3.0, 4.0 }
local myFile = assert( io.open( "myFile.dat", "wb" ) )
for i=1, #myNumbers do
	-- Write myNumbers[i] to file here as binary, 
	-- as if in C we had called 
	-- fwrite( &myNumbers[i], sizeof(myNumbers[i]), 1, myFile )
end


Thanks,
Daire


 
========================================
DISCLAIMER 

The contents of this e-mail and any attachments are confidential to the intended recipient and may also be legally privileged.  Unless you are the named addressee (or authorised to receive for the addressee) of this email you may not copy, disclose or distribute it to anyone else.  

If you have received this email in error, please notify us immediately by e-mail on administrator@sega.co.uk and then delete the email and any copies.  The SEGA Group have made all reasonable efforts to ensure that this e-mail and any attached documents or software are free from software viruses, but it is the recipient's responsibility to confirm this.

========================================



<<winmail.dat>>