How would you get the index of a dump bach.roll's body beginning if you don't want to dump the body but want to extract it from a whole dump?
My first intuitive answer was to search the last element of the header. As far as I understand this must be the loop information.
But I'm currently not sure if the header's last element is always the loop information. Could you confirm this or give me a better strategy?
Thanks
Bach.roll: getting the index of the headers last element
-
- Site Admin
- Posts: 1349
- Joined: Fri Dec 03, 2010 1:25 pm
Re: Bach.roll: getting the index of the headers last element
Hello. If you just need to slice the header you can use bach.sliceheader
If you want to know how this works, the idea is that the header goes on as long as there are lists of the kind
[ somesymbol .... ] [ someothersymbol ... ] ...
The first sublist not starting with a symbol is the beginning of the body, namely the first voice.
Best
Daniele
If you want to know how this works, the idea is that the header goes on as long as there are lists of the kind
[ somesymbol .... ] [ someothersymbol ... ] ...
The first sublist not starting with a symbol is the beginning of the body, namely the first voice.
Best
Daniele
Re: Bach.roll: getting the index of the headers last element
Great. That's the way I understood it.
So bach.sliceheader does under the hood something like:
## input is a full dump. We look for the body.
$input = $x1.right(1) ; ## take out router 'roll'
$inlen = $input.length() ; ## get length
$check = 0; ## init condition var
## loop through the dump
for $i $addr in 1 ... $inlen as $check < 1 do(
## check if the first entry is a symbol
if contains($input:$i:(1 1)) == 16 then $check = 0
else (
$check = 1 ;
$input:$i ## the current entry is the body
)
)
––––
I love contains()
Best,
Micha
So bach.sliceheader does under the hood something like:
## input is a full dump. We look for the body.
$input = $x1.right(1) ; ## take out router 'roll'
$inlen = $input.length() ; ## get length
$check = 0; ## init condition var
## loop through the dump
for $i $addr in 1 ... $inlen as $check < 1 do(
## check if the first entry is a symbol
if contains($input:$i:(1 1)) == 16 then $check = 0
else (
$check = 1 ;
$input:$i ## the current entry is the body
)
)
––––
I love contains()
Best,
Micha