Sorry, during copying there was a break off of two lines.
I hope it works now.
> In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] writes
> >As promised
> >
> >;msg: to-string read/binary %test/hl7/h0000024.hl7
> >
> >hl7: make object! [
> > msgtype: make block! 2
>
> Hi,
>
> I finally had some time to try this out today, and I get the following
> error..
>
> ** Syntax Error: Missing ] at end-of-paren.
> ** Where: (line 35) if seg [
>
> -------
> Regards, Graham Chiu
> gchiu<at>compkarori.co.nz
> http://www.compkarori.com/dynamo - The Homebuilt Dynamo
> http://www.compkarori.com/dbase - The dBase bulletin
>
--
Sent through Global Message Exchange - http://www.gmx.net
hl7: make object! [
msgtype: make block! 2
segsep: "^M"
fldsep: "|"
compsep: "^^"
repsep: "~"
escape: "\"
subsep: "&"
frame.start: none
frame.end: none
segments: make block! 50
segnumber: 0
ok: true
warning: none
in: func [ {should parse and check a message according HL7-Rules}
msg [string!] /local seg
] [
clear segments clear msgtype segnumber: 0 ok: true
parse msg [copy frame.start [ to "MSH" | to "FHS"] seg: (
append/only msgtype copy/part seg 3
fldsep: pick seg 4
either fldsep = pick seg 9 [
fldsep: to-string fldsep
compsep: to-string pick seg 5
repsep: to-string pick seg 6
escape: to-string pick seg 7
subsep: to-string pick seg 8
] [ok: false warning: "Delimiter"]
)
some [ copy seg to segsep (
if seg [
either fldsep/1 = pick seg 4 [
segnumber: :segnumber + 1
append/only segments to-word copy/part seg 3
seg: skip seg 4
append/only segments to-block parse/all seg fldsep
] [ok: false
warning: join "Header after segment nro " form segnumber]
]
) 1 skip
]
copy frame.end to end (
insert segments/msh fldsep
append/only msgtype replace copy segments/msh/9 compsep ""
)
]
return segments
]
msg: make string! 1000
out: func [{should generate a message according the HL7 rules} ] [
clear msg
fldsep: copy segments/msh/1
remove segments/msh
foreach [head body] segments [
append msg form head append msg fldsep
foreach fld body [append msg fld append msg fldsep]
append msg segsep
]
insert segments/msh fldsep
return msg
]
]