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 >
Text File  |  1996-12-05  |  3KB  |  63 lines

  1. #
  2. # TCL-procedure: createReports name_list
  3. #
  4. # The createReports procedure creates local sections which will allow
  5. # inclusion of actual reports in a document.
  6. # The argument name_list is a , sepperated list of report names without
  7. # the .tcl suffix for example: classes, events. storeFile and section
  8. # are pre-defined given by the environment. Also global $document is set.
  9.  
  10. proc w95comm {args} {
  11.     set e ""
  12.     set newargs ""
  13.         foreach e $args {
  14.                 regsub -all {/} $e {\\} e
  15.                 set newargs "$newargs $e"
  16.         }
  17.         return "COMMAND.COM /C $newargs"
  18. }
  19. proc createReport { name_list storeFile section } {
  20.  
  21.         # Prepare path_names
  22.         set M4repdir [path_name concat [m4_var get M4_home] reports]
  23.         set M4bindir [path_name concat [m4_var get M4_home] bin]
  24.  
  25.         # use the ClientContext to switch systems
  26.         set cc [ClientContext::global]
  27.  
  28.         # remember the current document-system we are in now
  29.         set currsys [$cc currentSystem]
  30.  
  31.         # get the system handle of the system we are documenting now
  32.         # the document object is a global set var in docbatch.tcl
  33.         set docsys  [$document docSys]
  34.  
  35.         # Change the context to the system to execute the report in
  36.         $cc changeLevelId $docsys
  37.  
  38.         # Set the first indent level to indent +
  39.         set indent +
  40.         # open the file in where the sub-structure will be generated
  41.         set fid [open $storeFile w]
  42.         # For each report name in the name_list run the (TCLbased) report-writer
  43.         foreach name [split $name_list " "] {
  44.            set name [string trim $name]
  45.            set tmpname [args_file {}]
  46.            puts "Executing TCL report writer for report $name.tcl"
  47.            # Run A command.com to redirect output
  48.        set command [w95comm "$M4bindir/otsh -f $M4repdir/startreport.tcl -- $name.tcl"]
  49.            puts "Running command $command"
  50.            system "$command > $tmpname"
  51.            # Now generate the additional structure lines note that the section
  52.            # name - must - differ from the name used in the .str file, e.g.
  53.            # the new section name must be unique. We use the the report name.
  54.            regsub -all {\\} $tmpname {\\\\} newtmp        
  55.            puts $fid "$name|$indent||DocText||$newtmp"
  56.            set indent =
  57.         }
  58.         # Close the sub-structure file
  59.         close $fid
  60.         # Go back to the context fo the current document system
  61.         $cc changeLevelId $currsys
  62. }
  63.