Hello, thanks for visiting GameML, if you are a Game Maker user, this is the site for you, please sign up, or login if you are already a member, or just browse the site! Welcome to GameML!

Log in

I forgot my password


Display results as :

Rechercher Advanced Search

Site Hits
Free hit counter
These stats started at 0 on July 7th 2009
GameML File Sharing
USERNAME: gamemladmin@gmail.com PASSWORD: gamemlsite Upload Here: http://gameml.iowoi.org/GameML-File-Sharing-h3.htmPlease add only games.
Make a Blog on GameML:http://gamemlblogs.wetpaint.com

Helping scripts for binary files

Go down

Helping scripts for binary files

Post by asmodeus on Thu Jul 16, 2009 11:22 am

Here are two helpful scripts for beginners, who want to write into binary files and read from them.

file_bin_var.gml contains the following two scripts:
file_bin_write_var(fp, val)

fp is the file id returned by file_bin_open() and val is any variable you want to write into the file, real values and strings can be stored and read.
You should delete an existing file bofre writing into it, because the final file size could change, and if it is smaller than before, the can be "rubish" at the end of the file.

For more experienced users binary_files.gml could be interesting. It contains functions to read and write words, dwords, custom sized values and strings.
file_bin_write_word(file, word[, little])
file_bin_write_dword(file, dword[, little])
file_bin_write_custom(file, size, val[, little])
file_bin_write_string(file, str, size, fill)
file_bin_read_word(file[, little])
file_bin_read_dword(file[, little])
file_bin_read_custom(file, size[, little])
file_bin_read_string(file, size)

word/dword/val/str is the value you want to write/read, little whether it is little or big endian (true=little, false=big (default)) and size is the size in bytes for reading/writing.

I hope these scripts are useful for you.

Last edited by asmodeus on Thu Jul 16, 2009 8:04 pm; edited 1 time in total
GameML Noob
GameML Noob

Posts : 12
Points : 32400
GameML Reputation : 5
Join date : 2009-07-15
Age : 25
Location : Germany

View user profile http://asmodeusgames.comze.com/index.php?p=1

Back to top Go down

Re: Helping scripts for binary files

Post by gogame1315 on Thu Jul 16, 2009 12:52 pm

very nice ! Very Happy
GameML Adventurer
GameML Adventurer

Posts : 103
Points : 34565
GameML Reputation : 10
Join date : 2009-07-10
Age : 22

View user profile http://www.yoyogames.com/members/gamesgo1315

Back to top Go down

Back to top

Permissions in this forum:
You cannot reply to topics in this forum