How to modify bytes in a binary file with RunRev

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
titobal
Posts: 31
Joined: Thu Aug 06, 2009 1:51 pm

How to modify bytes in a binary file with RunRev

Post by titobal » Sat Jan 23, 2010 7:22 pm

Hi all,

I would like to know if it is possible to modify bytes from a binary file using runrev ?

What I want to do for example is ... I load a binary file (which is a pure binary files filled with bytes),

then once loaded into a buffer I want to modify the 4th byte (offset $4) from the value it currently has (let say $80) into another value (let say $81 hex value)

then save this buffer into a new binary file...

How would you achieve that ?

Any help is greatly appreciated.

Thanks.

RRobert
Posts: 151
Joined: Sat Feb 28, 2009 8:20 pm

Re: How to modify bytes in a binary file with RunRev

Post by RRobert » Sun Jan 24, 2010 3:28 am

Hello,
I would like to know if it is possible to modify bytes from a binary file using runrev ?
Sure.
How would you achieve that ?
Load the file into a buffer, convert each character to a the hex value by using the baseConvert function. Make your changes and write the file back.

Robert

titobal
Posts: 31
Joined: Thu Aug 06, 2009 1:51 pm

Re: How to modify bytes in a binary file with RunRev

Post by titobal » Sun Jan 24, 2010 5:56 pm

Thanks rrobert,

could you provide couple sample code to do that ? I am really novice in runrev ;-)

TIA.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: How to modify bytes in a binary file with RunRev

Post by BvG » Sun Jan 24, 2010 6:43 pm

you can also use the binarencode and binarydecode stuff, but if you're just beginning with rev, i suggest to try something else then binary stuff first.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Post Reply