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

(No subject)Date: Mon, 11 Feb 2002 11:31:48 -0700

 [1/3] from: greggirwin::mindspring::com at: 11-Feb-2002 10:22


Hi Alessandro, << I have to parse a string like the following: SELECT SIZE MODIFIED FROM %/c/filetext.txt ... the problem is "action-2" holds either "size" or "modified" (not both) even if the user insert both of them. >> the 'set word, takes the next value, which will be the next word that matches the words in your rule. Even though you have alternates and 'some specified, it will only take the first one (parse experts correct me if I'm wrong here). I modified your rule slightly, to use 'copy instead of 'set. This version will copy everything after the action-1 word, up to the 'from clause in the source statement. I then changed the logic, so it uses 'find on action-2 to see if it contains something we're interested in. rule: [ set action-1 ['select | 'insert | 'update | 'delete] copy action-2 to 'from 'from set dir-1 file! ( if action-1 = 'select [ either action-2 = '* [ list-dir dir-1 ][ if find action-2 'size [print size? dir-1] if find action-2 'modified [print modified? dir-1] ] ] ) ] b: [SELECT SIZE MODIFIED FROM %/c/autoexec.bat] parse b rule b: [SELECT MODIFIED FROM %/c/autoexec.bat] parse b rule b: [SELECT SIZE FROM %/c/autoexec.bat] parse b rule You could also do something like this, where finding a specific action word adds that word to a block of actions. (watch out for word-wrap on this one) rule: [ set action-1 ['select | 'insert | 'update | 'delete] set action-2 ['* | some ['size (append actions 'size) | 'modified (append actions 'modified)] ] 'from set dir-1 file! ( if action-1 = 'select [ either action-2 = '* [ list-dir dir-1 ][ if find actions 'size [ print size? dir-1 ] if find actions 'modified [ print modified? dir-1 ] ] ] ) ] b: [SELECT SIZE MODIFIED FROM %/c/autoexec.bat] actions: copy [] parse b rule HTH! --Gregg

 [2/3] from: lmecir:mbox:vol:cz at: 12-Feb-2002 10:05


Hi, Here is my trial that eliminates If and Either from the rule: rule: [ (actions: copy []) star: none ['select (star: ['* (append actions [list-dir dir-1])]) | 'insert | 'update | 'delete] some [ star | 'size (append actions [size? dir-1]) | 'modified (append actions [modified? dir-1]) ] 'from set dir-1 file! (print reduce actions) ] b: [SELECT SIZE MODIFIED FROM %/c/autoexec.bat] parse b rule Cheers L

 [3/3] from: lmecir:mbox:vol:cz at: 12-Feb-2002 11:12


an improved version: rule: [ ( actions: copy [] action2: copy [ 'size (append actions [size? dir-1]) | 'modified (append actions [modified? dir-1]) ] ) [ 'select (append action2 [| '* (append actions [list-dir dir-1])]) | 'insert | 'update | 'delete ] some action2 'from set dir-1 file! (print reduce actions) ] b: [SELECT SIZE MODIFIED FROM %/c/autoexec.bat] parse b rule