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

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