home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / Tickle-4.0 (tcl) / scripts / WorkSheet.tcl < prev    next >
Encoding:
Text File  |  1993-11-05  |  1.7 KB  |  56 lines  |  [TEXT/$Tcl]

  1.  
  2. foreach name [espace This is a test] { print "$name\n" }
  3. foreach name {This is a test} { print "$name\n" }
  4.  
  5. print [length {This is a test} chars]
  6. print [range abcdefghijklmnopqrstuvwxyz 10 15 chars]
  7. print [time {print "time run\n"} 100]
  8.  
  9. foreach cmd [info commands] { print "$cmd\n" }
  10. foreach cmd [info globals] { print "$cmd\n" }
  11. foreach cmd [info locals] { print "$cmd\n" }
  12. foreach cmd [info procs] { print "$cmd\n" }
  13. foreach cmd [info tclversion] { print "$cmd\n" }
  14. foreach cmd [info vars] { print "$cmd\n" }
  15. foreach cmd [info tclversion] { print "$cmd\n" }
  16.  
  17. print [history info]
  18.      1  print "[espace This is a test]\n"
  19.      2  foreach name [espace This is a test] { print "$name\n" }
  20.      3  foreach name {This is a test} { print "$name\n" }
  21.      4  history info 1
  22.      5  history info 2
  23.      6  print history info 2
  24.      7  print [history info 2]
  25.      8  print [history info]
  26.  
  27. ###
  28. ### This will generate MPW style output to open and locate
  29. ### lines containing a regular expression we specify.
  30. ###
  31. proc cool_search { globexp regexp open_cmd line_cmd } {
  32.     foreach file [glob $globexp] {
  33.         set SC [scancontext create]
  34.         scanmatch $SC $regexp {
  35.             puts stdout "$open_cmd $file; $line_cmd $matchInfo(linenum); # $matchInfo(line)"
  36.             }
  37.  
  38.         set FD [open $file r]
  39.  
  40.         scanfile $SC $FD
  41.  
  42.         close $FD
  43.         scancontext delete $SC
  44.         }
  45.     }
  46.  
  47. ### Tickle Version
  48. cool_search "Fire:MPW:src:tickle:tcl:*.h" {^#.*include} "open_text" "Line"
  49.  
  50. ### MPW Version
  51. cool_search "Fire:MPW:src:tickle:tcl:*.h" {^#.*include} "File" "Line"
  52.  
  53. File Fire:MPW:src:tickle:tcl:tcl.h; Line 34; # #include <stdio.h>
  54. File Fire:MPW:src:tickle:tcl:tclExtend.h; Line 22; # #include <stdio.h>
  55. File Fire:MPW:src:tickle:tcl:tclExtend.h; Line 23; # #include "tcl.h"
  56.