Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: my-data

From: greggirwin:mindspring at: 22-Jul-2002 11:14

Hi Jim, There are times when I like to spin through a text file and just do the work as I go. Most times, though, I tend to load the data into structures that I can work with more easily, especially in apps that have a UI of some kind as opposed to batch processing type apps. Anyway, I went a different direction because I didn't quite grok your example, so you can ignore this if it's not to your liking. ; Create a prototype object ; TO and FOR are keywords we don't want to conflict with exp-rec: make object! [ date: check-number: to*: for*: exp-1: exp-2: exp-3: none ] records: copy [] fields: next first exp-rec my-data: read/lines 02.exp ; Load the data into a block of objects. ; You could also just make a block of blocks if you want. foreach :fields my-data [ new-rec: make exp-rec [] new-rec/date: date new-rec/check-number: check-number new-rec/to*: to* new-rec/for*: for* new-rec/exp-1: to money! either not empty? exp-1 [exp-1][0] new-rec/exp-2: to money! either not empty? exp-2 [exp-2][0] new-rec/exp-3: to money! either not empty? exp-3 [exp-3][0] append records new-rec ] ; Now you can work with the objects to do whatever you want. total: $0.00 foreach rec records [ total: total + rec/exp-1 ] print total halt HTH! --Gregg