writing to binary data at arbitrary position

Viktoras Didziulis viktoras at ekoinf.net
Sat Sep 16 03:53:28 EDT 2006


Thanks Dar! 
 
This is exactly (manipulating imageData) what I was looking for.
 
Best wishes 
Viktoras 
 
-------Original Message------- 
 
From: Dar Scott 
Date: 09/15/06 23:48:39 
To: How to use Revolution 
Subject: Re: writing to binary data at arbitrary position 
 
On Sep 15, 2006, at 12:09 PM, Viktoras Didziulis wrote: 
 
> What is the fastest way (in Rev), for instance, to insert 3 bytes 
> of binary 
> data after the 465th byte of data stored in variable myVar using 
> put, seek 
> or whatever else is available? Or is the repeat loop the only way 
> to do 
> this?.. 
 
If you mean that the bytes after the 465th byte are shifted down, 
then the method Mark Smith mentioned would work. If you mean that 
you want to replace bytes 466, 467 and 468, then you can do this: 
 
put binDat into char 466 to 468 of myVar 
 
(There is a feature request in bugzilla to allow the word 'byte' in 
this context.) 
 
How you create binDat depends on the form of the binary data. Look 
at the binaryEncode() function. Exactly how you would use that 
depends on whether you need 3 byte numbers, a single 24-bit number or 
a byte plus a 16-bit number or something else. 
 
You can also use numToChar() to create a byte that you think of as 
binary. However, my opinion on this has changed and I now encourage 
use of binaryEncode() even for single bytes. With binaryEncode() you 
can encode all three values at once. 
 
If you are working with imageData and are replacing pixels, then this 
is the way to go. If you are building a new imageData, don't forget 
the 0 byte--build all 4 bytes at once and then append to the variable 
with 'put...after...'. 
 
Dar 
 
-- 
************************************** 
Dar Scott 
Dar Scott Consulting and Dar's Lab 
8637 Horacio Place NE 
Albuquerque, NM 87111 
 
Lab, office, home: +1 505 299 9497 
Fax: call above first 
Skype: ask 
 
http://www.swcp.com/dsc 
dsc at swcp.com 
 
Computer programming 
************************************** 
 
 
_______________________________________________ 
use-revolution mailing list 
use-revolution at lists.runrev.com 
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences: 
http://lists.runrev.com/mailman/listinfo/use-revolution



More information about the use-livecode mailing list