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

[REBOL] Re: Parse Problem

From: greggirwin:mindspring at: 29-Oct-2001 16:33

Hi Louis, << Why doesn't the following program work? It should find field/1 in ibidem and replace it with field/2 (see Modify the String in the Parsing section of the Users Guide). >> Hopefully someone will correct me if I misinform you, but here's my analysis and a solution. In your call to parse, field/1 is not recognized because while parse can get word values, it doesn't seem to allow a path reference on a word. That's my guess anyway. The part of the code inside parenthesis can be valid REBOL code, not just parse dialect, so it's OK in there. The solution is to set a temporary variable and use that (see below). The other thing I added was to use the /part refinement with change. Since you're substitution is longer than what you're replacing, you'll overwrite other data just using change. foreach field fields [ foreach ibidem ibidems [ f1: field/1 parse ibidem [any [to f1 mark: (change/part mark field/2 length? f1) skip]] ] ] HTH! --Gregg