Hello, I've been working on a script to take a file, sum the detail records
and compare to a total on a trailer record, which i have enclosed at the
end of this message.

The following shows 2 runs of the script, using different files that i put
together, one shows "BALANCED" and the other "NOT BALANCED", even though
the totals agree!!!

Even allowing for the fact that i might not be using the best use of
"to-money" and " / 100", it should still give consistent results, shouldn't
it ???


Script: "Untitled" (none)
HEADER FOUND!!
TRAILER FOUND!!
RECS READ =  41
TOTAL     =  $410604386.69
TRAILER   =  $410604386.69
BALANCED

Script: "Untitled" (none)
HEADER FOUND!!
TRAILER FOUND!!
RECS READ =  7112
TOTAL     =  $410604386.69
TRAILER   =  $410604386.69
NOT BALANCED

***************** BEGIN SCRIPT ***************
REBOL []


file: read/lines %g01m0131.txt

type:

recs: 0

total:

ee:
tot_ee: 0


foreach line file [
      type: (copy/part line 2)
      
      if type = "00" [print "HEADER FOUND!!"]
      if type = "01" [
      recs: recs + 1
      line: skip line 58
      ee: (copy/part line 10)
      ee: to-money ee
      tot_ee: tot_ee + ( ee / 100)]
        if type = "99" [print "TRAILER FOUND!!"
                      line: skip line 12
                      total: to-money (copy/part line 12)
                      total: total / 100]
                      

      
]
print ["RECS READ = " recs]
print ["TOTAL     = " tot_ee]
print ["TRAILER   = " total]

if total = tot_ee [print "BALANCED"]
if total <> tot_ee [print "NOT BALANCED"]



***************** END SCRIPT ***************


Mike.   

Reply via email to