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

  1. #----------------------------------------------------------------------------
  2. #
  3. #    (c) Cadre Technologies Inc. 1995
  4. #
  5. #    File:        %W%
  6. #    Author:        Harm Leijendeckers
  7. #    Description:    Start script for all standard reports. It should
  8. #            be sourced with the desired report as argument.
  9. #            fe: otsh -f startreport.tcl -- projects.tcl
  10. #    Needed files:    $M4_home/reports/rwsource.tcl
  11. #            $M4_home/reports/reportbase.tcl
  12. #
  13. #----------------------------------------------------------------------------
  14. # SccsId = %W%    %G%    Copyright 1995 Cadre Technologies Inc.
  15.  
  16.  
  17. #
  18. # Check arguments
  19. #
  20. set reportName [lvarpop argv]
  21. if { $reportName == "" } {
  22.     error "Need argument report name"
  23. }
  24.  
  25. global Options
  26. if { [lindex $argv 0] == "-o" } {
  27.     lvarpop argv
  28.     set Options $argv
  29.  
  30.     if { $Options == "" } {
  31.     error "Option -o needs argument(s)"
  32.     }
  33. } else {
  34.     set Options ""
  35. }
  36.  
  37.  
  38. #
  39. # Source scripts
  40. #
  41. OTShRegister::reportWriter
  42. set cc [ClientContext::global]
  43. eval [$cc getCustomFileContents rwsource tcl reports]
  44. eval [$cc getCustomFileContents reportbase tcl reports]
  45.  
  46. #
  47. # Source report
  48. #
  49. set root [file root $reportName]
  50. set userReport [path_name concat [location ~ icase] $root tcl]
  51. if [file isfile $userReport] {
  52.     source $userReport
  53. } else {
  54.     if [$cc customFileExists $root tcl reports] {
  55.     eval [$cc getCustomFileContents $root tcl reports]
  56.     } else {
  57.     if [file isfile $reportName] {
  58.         source $reportName
  59.     } else {
  60.         error "Can't open file $reportName"
  61.     }
  62.     }
  63. }
  64.  
  65.  
  66. #
  67. # Check if this is a converted report
  68. #
  69. if [info exists CONVERTED] {
  70.     eval [$cc getCustomFileContents startconvrep tcl reports]
  71.     return
  72. }
  73.  
  74.  
  75. #
  76. # Execute report and show traceback if an error occured
  77. #
  78. if { ![string length [info var executeMe]] } {
  79.     error "Do not know how to execute report $reportName"
  80. }
  81.  
  82. if { [catch { $executeMe execute } string] == 1 } {
  83.     puts $errorInfo
  84.     exit
  85. }
  86.  
  87. #
  88. # If nothing was printed (pageno == lineno == 0)
  89. #
  90. if { !([[$executeMe report] pageno] || [[$executeMe report] lineno]) } {
  91.     puts "Report: [$executeMe reportName] -- No appropriate data found"
  92. }
  93.