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

Bill
Posts: 45
Joined: Sat Apr 08, 2006 8:22 pm
Contact:

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

MaxV
Posts: 1574
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Reading Binaries int8, int32 etc.

• 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: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

FourthWorld
VIP Livecode Opensource Backer
Posts: 6717
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Reading Binaries int8, int32 etc.

FWIW "uint1", uint2", and "uint4" are valid chunk types that can be used with reading and writing files and parsing data. See those Dictionary entries for examples.
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com

MaxV
Posts: 1574
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Reading Binaries int8, int32 etc.

Uint in dictionary is not explained well. Please can yo write here what is it?
Is it int32 or 16 or else?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

FourthWorld
VIP Livecode Opensource Backer
Posts: 6717
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Reading Binaries int8, int32 etc.

These are standard terms:
uint1 = 1 byte
uint2 = 2 bytes
unit4 - 4 bytes

To read 4 bytes from a file you could ask it for that:

Code: Select all

``read from file tFile for 4 bytes``
``read from file tFile for 1 unit4``