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

[REBOL] finding balanced occurences of two words... help needed

From: princepawn::mailandnews::com at: 15-Sep-2000 4:53

REBOL [ Title: {Unbalanced set and reset commands alert function. Prints a warning when a file contains an unbalanced number of setsize and resetsize commands. Right now, for some reason, it only seems to count the resetsize text and not increment set-cmds... }] study-file: func [file [file!] /local set-cmds reset-cmds] [ set-cmds: 0 reset-cmds: 0 s-size: [thru "setsize" (set-cmds: set-cmds + 1)] rs-size: [thru "resetsize" (reset-cmds: reset-cmds + 1)] rules: [any [rs-size | s-size] ] parse read file rules if (set-cmds <> reset-cmds) [ print reform [ "file" file "had unbalanced set and reset cmds" set-cmds "set-cmds" reset-cmds "reset-cmds" ] ] ] write %dummyfile1 "setsize" write %dummyfile2 "setsize setsize resetsize" foreach file [ %dummyfile1 %dummyfile2 ] [ study-file file ] terrence-brannon: [[princepawn--yahoo--com] perl-refugee myth-gamer] free-email: free-usenet: ; all the above is real REBOL code, believe it or not.