Reading Binaries int8, int32 etc.

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
Posts: 45
Joined: Sat Apr 08, 2006 8:22 pm
Location: Colorado

Reading Binaries int8, int32 etc.

Post by Bill » Sun May 20, 2018 5:13 am

Er..int16 not int8

Trying to extract data from Tim Phillip's Realmz.

How should I go about doing this?
This is the sequence of data in Data BD file, other files have other ranges.
The Mac OS Classic resources are a whole other beast to tackle.
169 is the number of entries.
I assume I read then as pos,dist,mystery,beforeBattle, afterBattleStringID, battleStringOD
but how? read from file for 16 int1 or 4 int 4?
  • int16[169] Position of monster in 13x13 grid.
    byte Distance from party
    byte ???
    int16 Before battle string id
    int16 After battle string id (Displayed when collecting treasure)
    int16 ???
Is the files are actually in Scenario folder of the game

This git has some details about the data

Thanks in advance.

Posts: 1541
Joined: Tue May 28, 2013 2:20 pm
Location: Italy

Re: Reading Binaries int8, int32 etc.

Post by MaxV » Wed Dec 12, 2018 1:01 pm

  • Int8: 1 byte
  • Int16: 2 bytes
  • Int32 : 4 bytes
  • Int64 : 8 bytes
So just use bytetonum this way:

Code: Select all

put bytetonum(byte myByteposition of myData) #int8
put  256 * bytetonum(byte myByteposition of myData) +  bytetonum(byte (myByteposition - 1) of myData) # int16
put  256* 256* 256 * bytetonum(byte myByteposition of myData)  + 256* 256 * bytetonum(byte (myByteposition - 1) of myData) +  256 * bytetonum(byte (myByteposition - 2 ) of myData) +  ( byte (myByteposition - 3 ) of myData) # int32
# and so on..
Livecode Wiki:
My blog:
To post code use this:

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”