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: [[EMAIL PROTECTED] perl-refugee myth-gamer]
free-email:       http://www.MailAndNews.com
free-usenet:      http://www.mailAndNews.com
; all the above is real REBOL code, believe it or not.

Reply via email to