Jump to content

Writing data to the files


DiSaMe

Recommended Posts

Is there any way of writing fixed number of bytes from any data type? For example, if a string is shorter than specified number of bytes, it would be lengthened with bytes that have value 0 (byte number, not a character "0"). And no need to convert number to string? I don't want to convert 4-byte value to the longer non-fixed length string by making it harder to read...

Link to comment

Check out the string.char and string.rep functions in the Lua manual.

I have to say though that messing around like this to store an integer seems rather hacky. Unless for some reason you have no choice but to use binary files, I would recommend using an .xml file or an SQLite or other database.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...