Odd behavior using copy/part?
[1/4] from: webmaster::siliconspecies::com at: 4-Jan-2001 1:31
I have a function which reads the header of a binary file and extracts
certain bits for analysis.
It seems to work fine until
home: copy/part header 1
Then it craps out. And the copy function which is Rebol native function
returns as a variable instead of copy.
You type Help Copy in Rebol/Command after this and it will tell you that
copy is either worth 8 or no help for copy or something similar.
Which I find distressing, the only way to restore the copy command in
Rebol/Command is to close and restart.
The solution I implemented was to kill at least half of the code below and
only extract info that was absolutely necessary instead of the whole thing.
code snippet:
variable: head variable
header: copy/part variable 4
header: enbase/base header 2 ;changes it to true binary which is like
11111111111110111001001100000000
sync: copy/part header 12
header: skip header 12
ID: copy/part header 1
header: skip header 1
layer: copy/part header 2
header: skip header 3
prot: copy/part header 1
header: skip header 1
bitrate: copy/part header 4
header: skip header 8
freq: copy/part header 2
header: skip header 2
pad: copy/part header 1
header: skip header 1
priv: copy/part header 1
header: skip header 1
mode: copy/part header 2
header: skip header 2
modext: copy/part header 2
header: skip header 2
copy: copy/part header 1
header: skip header 1
home: copy/part header 1
header: skip header 1
emphasis: copy/part header 1
Thanks,
Jeff
[2/4] from: rebol:techscribe at: 4-Jan-2001 0:25
Hi Jeff,
your problem is the following line (5 lines from the bottom of the code
your included in your email):
> copy: copy/part header 1
Here you are setting the word copy to the result of copy/part header 1
If you should encounter a problem like this again the easiest way of
detecting it is by starting your code off with the function
protect-system
This will result in an error message when you attempt to set one of
REBOL's predefined words to a new value, as is the case here.
Pretty sure this helps ;-)
Elan
Jeff Rubin wrote:
[3/4] from: al:bri:xtra at: 4-Jan-2001 22:03
> I have a function which reads the header of a binary file and extracts
certain bits for analysis.
> sync: copy/part header 12
> header: skip header 12
> ID: copy/part header 1
> header: skip header 1
> layer: copy/part header 2
> header: skip header 3
Easier might be:
Sync: copy/part at Header 1 12
ID: copy/part at Header 13 1
Layer: copy/part at Header 15 2
and so on.
I hope that helps!
Andrew Martin
Absolute Rebol...
ICQ: 26227169 http://members.nbci.com/AndrewMartin/
[4/4] from: webmaster:siliconspecies at: 4-Jan-2001 7:57
duh I must be blind :]