home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / w95docprocs_add.tcl < prev    next >
Encoding:
Text File  |  1996-12-05  |  2.5 KB  |  63 lines

  1. #
  2.  
  3. # TCL-procedure: createReports name_list
  4.  
  5. #
  6.  
  7. # The createReports procedure creates local sections which will allow
  8.  
  9. # inclusion of actual reports in a document.
  10.  
  11. # The argument name_list is a , sepperated list of report names without
  12.  
  13. # the .tcl suffix for example: classes, events. storeFile and section
  14.  
  15. # are pre-defined given by the environment. Also global $document is set.
  16.  
  17.  
  18.  
  19. proc w95comm {args} {
  20.  
  21.     set e ""
  22.  
  23.     set newargs ""
  24.  
  25.         foreach e $args {
  26.  
  27.                 regsub -all {/} $e {\\} e
  28.  
  29.                 set newargs "$newargs $e"
  30.  
  31.         }
  32.  
  33.         return "COMMAND.COM /C $newargs"
  34.  
  35. }
  36.  
  37. proc createReport { name_list storeFile section } {
  38.  
  39.  
  40.  
  41.         # Prepare path_names
  42.  
  43.         set M4repdir [path_name concat [m4_var get M4_home] reports]
  44.  
  45.         set M4bindir [path_name concat [m4_var get M4_home] bin]
  46.  
  47.  
  48.  
  49.         # use the ClientContext to switch systems
  50.  
  51.         set cc [ClientContext::global]
  52.  
  53.  
  54.  
  55.         # remember the current document-system we are in now
  56.  
  57.         set currsys [$cc currentSystem]
  58.  
  59.  
  60.  
  61.         # get the system handle of the system we are documenting now
  62.  
  63.         # the document object is a global set var in docbatch.tcl
  64.  
  65.         set docsys  [$document docSys]
  66.  
  67.  
  68.  
  69.         # Change the context to the system to execute the report in
  70.  
  71.         $cc changeLevelId $docsys
  72.  
  73.  
  74.  
  75.         # Set the first indent level to indent +
  76.  
  77.         set indent +
  78.  
  79.         # open the file in where the sub-structure will be generated
  80.  
  81.         set fid [open $storeFile w]
  82.  
  83.         # For each report name in the name_list run the (TCLbased) report-writer
  84.  
  85.         foreach name [split $name_list " "] {
  86.  
  87.            set name [string trim $name]
  88.  
  89.            set tmpname [args_file {}]
  90.  
  91.            puts "Executing TCL report writer for report $name.tcl"
  92.  
  93.            # Run A command.com to redirect output
  94.  
  95.        set command [w95comm "$M4bindir/otsh -f $M4repdir/startreport.tcl -- $name.tcl"]
  96.  
  97.            puts "Running command $command"
  98.  
  99.            system "$command > $tmpname"
  100.  
  101.            # Now generate the additional structure lines note that the section
  102.  
  103.            # name - must - differ from the name used in the .str file, e.g.
  104.  
  105.            # the new section name must be unique. We use the the report name.
  106.  
  107.            regsub -all {\\} $tmpname {\\\\} newtmp        
  108.  
  109.            puts $fid "$name|$indent||DocText||$newtmp"
  110.  
  111.            set indent =
  112.  
  113.         }
  114.  
  115.         # Close the sub-structure file
  116.  
  117.         close $fid
  118.  
  119.         # Go back to the context fo the current document system
  120.  
  121.         $cc changeLevelId $currsys
  122.  
  123. }
  124.  
  125.