I used the following snippet to translate logic analyzer trace files (which have fixed width fields, many of which I want to skip) into something that our simulators like. The file was read using read/lines into a block (tracelines) which was then parsed by the following:
rule: [
16 skip copy adr 8 skip
4 skip copy ts 2 skip
6 skip copy tt 4 skip
4 skip copy tbst 4 skip
20 skip copy aack 4 skip
4 skip copy artry 5 skip
11 skip copy dti 6 skip
6 skip copy dbg 3 skip
5 skip copy ta 2 skip
6 skip copy dh 8 skip
4 skip copy dl 8 skip
24 skip copy time 10 skip
to end]
s: " "
trc: func [] [
foreach l tracelines [
parse/all l rule
print rejoin [time s ts s tt s adr s aack s artry s dbg
s ta s dh s dl]
]
]
Ron
[EMAIL PROTECTED] wrote:
Has anyone written any REBOL scripts to read fixed width/format fields
in flat files? Files with fields separated solely by position? I sure
that 'parse could handle it, but I'm uncertain in this area. Currently
I'm using 'read-io with various record lengths to handle each separate
field, but this seems like an excessively complicated and slow
approach.Andrew Martin
[EMAIL PROTECTED]
http://members.xoom.com/AndrewMartin/
Online @ 33,600 Baud!
-><-