Thanks very much for your help. I'm now getting into unpacking data
structures from the bitstreams, but this is getting me some horrible code,
to whit stuff like this:
TUPLE: scData creator type ver num name reverb-character reverb-prelpf
reverb-time reverb-delay reverb-predelay reverb-level
reverb-selected chorus-prelpf chorus-feedback chorus-delay chorus-rate
chorus-depth chorus-sendrev chorus-senddelay
chorus-level chorus-selected delay-prelpf delay-timecenter
delay-timeratioleft delay-timeratioright delay-levelcenter
delay-levelleft delay-levelright delay-feedback delay-sendreverb
delay-level delay-selected masterbar-recall-register
index-icon bassoon edited junk unknown ;
: parse-sc ( -- head ) test "SC" get-chunk first
{ [ 4 7 bsread-string ] ! Creator
[ 4 7 bsread-string ] ! Type
[ 4 7 bsread-string ] ! Ver
[ 4 7 bsread-string ] ! Num
[ 8 7 bsread-string ] ! Name
[ 7 swap bsread ] ! Reverb Character
[ 7 swap bsread ] ! Reverb Prelpf
... And so on for a whole bunch of lines ...
[ 7 swap bsread ] ! Bassoon
[ 7 swap bsread ] ! Edited
[ 15 swap bsread ] ! Dummy
[ 57 7 bsread-string ] ! Unknown
} cleave scData boa ;
Now, I know I could make this much shorter by not repeating the quotations
but that has the problem that I then lose the comments and easy
editability. But! I have dipped my toe into LISP and it would be rather
fantastic to have a macro so that I could write something like:
FORMAT: scData creator ascii 4 7 type ascii 4 7 ver ascii 4 7 num ascii 4 7
name ascii 8 7 reverb-character integer 8 1 ...
And have that create the tuple and function above. Of course, I have no
idea how to do that - I've tried playing with the MACRO: and SYNTAX:
statements but I don't know how SYNTAX: takes input and MACRO: seems to
work using quotations in a way I'm not really used to from LISP style - I'm
guessing I need a whole new world of understanding the parser to do this.
Any inspirations?
Mark
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk