I have a tclproc that creates a seperate file for each message and ftps them to a server.
I need to add to this proc to include a a log file that will be picked up by the vendor every hour , and needs a message
count at the top of the file.
I have the audit file generating ok where i copy the message and create the log.
The thread protocol is ftp and its ftping the file and creating the log file , but my problem is , i need to be able to count
the no of messages in the log file before i write to it and appent a count to the top of the file. Hope this makes sense,
A snip of the code is as follows tha generates the audit log and is a as follows:
set mh2 [msgcopy $mh]
set msg [msgget $mh2]
set MSHSeg [getHL7Segment $msg “MSH”]
set c_createdate [getHL7Field $MSHSeg 6]
msgset $mh2 “
set newfilename “pims/data/audit.txt”
keylset alist OBFILE $newfilename
keylset fslist FILESET $alist
msgmetaset $mh2 DRIVECTL $fslist
lappend dispList “CONTINUE $mh2”
The file generates the following:
What I need is something similar to this
I have worked out the TCL to count the no of messages in any file by using the
set fh [open y:/quovadx/test.txt r]
set count 0
set srch “UniqueID”
while {[gets $fh line] >=0 } {
if regexp $srch $line]} {
incr count }
}
}
close $fh
puts $count
return $count
What I need to do is just before I write to the audit log I need to count the no of messages and append to the top of the
file, but am not sure how to go about it. I hope all this makes sense.
Any help would be great
Thanks
Ray