home *** CD-ROM | disk | FTP | other *** search
- #----------------------------------------------------------------------------
- #
- # (c) Cadre Technologies Inc. 1995
- #
- # File: %W%
- # Author: Harm Leijendeckers
- # Description: Start script for all standard reports. It should
- # be sourced with the desired report as argument.
- # fe: otsh -f startreport.tcl -- projects.tcl
- # Needed files: $M4_home/reports/rwsource.tcl
- # $M4_home/reports/reportbase.tcl
- #
- #----------------------------------------------------------------------------
- # SccsId = %W% %G% Copyright 1995 Cadre Technologies Inc.
-
-
- #
- # Check arguments
- #
- set reportName [lvarpop argv]
- if { $reportName == "" } {
- error "Need argument report name"
- }
-
- global Options
- if { [lindex $argv 0] == "-o" } {
- lvarpop argv
- set Options $argv
-
- if { $Options == "" } {
- error "Option -o needs argument(s)"
- }
- } else {
- set Options ""
- }
-
-
- #
- # Source scripts
- #
- OTShRegister::reportWriter
- set cc [ClientContext::global]
- eval [$cc getCustomFileContents rwsource tcl reports]
- eval [$cc getCustomFileContents reportbase tcl reports]
-
- #
- # Source report
- #
- set root [file root $reportName]
- set userReport [path_name concat [location ~ icase] $root tcl]
- if [file isfile $userReport] {
- source $userReport
- } else {
- if [$cc customFileExists $root tcl reports] {
- eval [$cc getCustomFileContents $root tcl reports]
- } else {
- if [file isfile $reportName] {
- source $reportName
- } else {
- error "Can't open file $reportName"
- }
- }
- }
-
-
- #
- # Check if this is a converted report
- #
- if [info exists CONVERTED] {
- eval [$cc getCustomFileContents startconvrep tcl reports]
- return
- }
-
-
- #
- # Execute report and show traceback if an error occured
- #
- if { ![string length [info var executeMe]] } {
- error "Do not know how to execute report $reportName"
- }
-
- if { [catch { $executeMe execute } string] == 1 } {
- puts $errorInfo
- exit
- }
-
- #
- # If nothing was printed (pageno == lineno == 0)
- #
- if { !([[$executeMe report] pageno] || [[$executeMe report] lineno]) } {
- puts "Report: [$executeMe reportName] -- No appropriate data found"
- }
-