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

[REBOL] To do or not to do?

From: sanghabum:aol at: 28-Nov-2001 15:40

Hi all, It may just be my irredeemably old-fashioned mindset, but everywhere I turn in Rebol I see the need to 'DO strings. I've been ticked off before on the list about it and -- these days -- I can normally see better approaches. But this little example has got me stumped. So I'm interested in how the gurus would unDo my approach. The code below is the proof-of-concept, back of the envelope idea that many data entry validation rules can be written to a database as Rebol code. I just then need to write a single apply-the-rules function, and add a little code for special cases, rather than write buckets of repetitive code. But its got a DO string in it. Any comments? --Colin ---------------------------------- ;; rules table ;; =========== Rules: [ "(Length? to-string *) > 0" "No data" "date? *" "Bad date" "(* - 14 ) < now/date" "Too old" "specialcheck * " "Not special" ] ;; prepare data field ;; ============== RawValue: "5-122-2001" ;; bad date in this example Loadedvalue: "" if error? try [loadedValue: first load/all Rawvalue] [LoadedValue: RawValue] ;; apply rules ;; =========== foreach [rule message] Rules [ if not (do replace/all copy rule "*" mold LoadedValue) [ print [LoadedValue " fails rule: " Message] break ] ; if ] ; for