On 24/7/00 4:16 pm, James Parker <[EMAIL PROTECTED]> wrote:

> What is the trick to working with binary data in MetaCard?
> 
> It's easy enough to open a binary file and read in the data and then open
> another binary file for write to write out the data but how do you
> manipulate the data once you've read it in?
> 
> Let's say I want to bitAnd every byte with 254 or change every 16th word
> to all zeros, for example.
> 
> Will MetaCard do this?

It should be easy enough: just don't put the data into a field at any point
or it will get converted to text! ;-)  Check out the bitwise operators in
the reference for bitAnd, and also the charToNum / numToChar and itemDel
entries.

You need to be careful what type of repeat loop you use on the data.  If
there is a small amount of data, you can get away with repeat with i = 1 to
the number of chars, altering char i in the original data.  If there is even
a moderate amount of data though, this is not going to be so efficient as
this method will search from the beginning of the string each time.  So you
need to rebuild the container by using repeat for each char c.  E.g.:

put empty into tFinalData --not strictly required, but included for clarity
repeat for each char c in tFileData
  -- do something to c here, e.g. with bitAnd
  put c after tFinalData
end repeat
--tFinalData now contains the replaced text

Regards,

Kevin

Kevin Miller <[EMAIL PROTECTED]> <http://www.runrev.com/>
Runtime Revolution Limited (formerly Cross Worlds Computing).
Tel: +44 (0)131 672 2909.  Fax: +44 (0)1639 830 707.


Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to