home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
exp2file.tcl
< prev
next >
Wrap
Text File
|
1996-08-12
|
6KB
|
161 lines
# ~/icase/export_to_file.tcl
#
# Created: 15 februari 1996
# Updated: 15 april 1996
# Version: 1.2
# Purpose: To export a diagram to a file (supplied by the user via 'FileSelect'
# Notes on V1.1: Made compatible with new 'et.tcl' (OMT V4.0/01)
# Notes on V1.2: generalized the file selection procedure (platform independent)
#
#puts "Using ~/icase/export_to_file.tcl"
# -----------------------------------------------------------
# retrieve my own small library of commonly usable procedures
# -----------------------------------------------------------
set home [lindex [glob ~] 0]
source "[path_name concat [path_name concat $home icase] small_library.tcl]"
proc usage {} {
puts "Usage: otsh ~/icase/export_to_file.tcl -- [<diagram name> ...]"
exit 1
}
# ------------------------------------
# A procedure to process all arguments
# ------------------------------------
proc exportDiagrams { diagrams level } {
set argv ""
set processed 1
set hasBeenSourced 0
set to_process [llength $diagrams]
set line "--------------------------------------"
set line "$line$line"
foreach diagram $diagrams {
set path $level/$diagram
set ok [[ClientContext::global] setLevelPath $path]
# --------------
# Error handling
# --------------
if { $ok } {
puts " Can't determine client context: '$env(M4_levelpath)'"
puts " Program stops, whithout export generation. "
exit 1
}
# -----------------------------
# Feedback progress to the user
# -----------------------------
puts "Select a file to which the following tcl diagram must be written."
puts -nonewline "Diagram '$diagram' ($processed of $to_process) ... "
flush stdout
set processed [ expr $processed + 1 ]
# --------------------------------------------------
# Prompt the File selection dialog and handle errors
# --------------------------------------------------
set file_name "[FileSelect]"
if { $file_name == "" } {
puts "File name empty, can't comply"
#[ClientContext::global] setLevelPath $oldM4_levelpath
exit 1
}
if { [file exists $file_name] } {
if { [file type $file_name] != "file" } {
puts "File '$file_name' not a file, can't comply"
#[ClientContext::global] setLevelPath $oldM4_levelpath
exit 1
}
if { ! [file writable $file_name] } {
puts "File '$file_name' not writable (for you), can't comply"
#[ClientContext::global] setLevelPath $oldM4_levelpath
exit 1
}
# -------------------------------------------------------------
# in the future an extra question to the user if he/she is sure
# -------------------------------------------------------------
}
# -------------------------------------------------------------
# store some essential data in the file and append exported tcl
# -------------------------------------------------------------
set f [open $file_name w]
puts $f "# $line"
puts $f "# export by '[get_user_name]' on [date]."
puts $f "# diagram = '$level/$diagram'."
puts $f "# $line"
puts $f ""
flush $f
close $f
# -----------------------------------------------------------
# set the arguments and execute the exportTool procedure body
# -----------------------------------------------------------
set version "40[string range [versionInfo maintVersion] 0 1]"
set args "[list -a$file_name] -vi$version -vo$version -i -l"
eval exportTool { $args }
# -----------------------------
# Feedback progress to the user
# -----------------------------
puts "exported."
flush stdout
}
}
# --------------------------------------------------------------
# See if any boolean options were specified, set the appropriate
# variables, and remove any options from argv.
# --------------------------------------------------------------
proc exportMain {} {
global ucgargv
global et_dont_run
# -------------------------------------------------------------------
# source the export source without executing the procedure exportTool
# -------------------------------------------------------------------
set src "[path_name concat [lindex [glob ~] 0] icase]"
set src "[path_name concat $src get_export_source.tcl]"
source "$src"
# -----------------------
# setup the ClientContext
# -----------------------
set clientContext [ClientContext::global]
set corporate [[$clientContext currentCorporate] name]
set project [[$clientContext currentProject] name]
set configuration [[[$clientContext currentConfig] config] name]
set version [[$clientContext currentConfig] versionNumber]
set phase [[[$clientContext currentPhase] phase] name]
set system [[[$clientContext currentSystem] system] name]
#puts "corporate = $corporate"
#puts "project = $project"
#puts "configuration = $configuration"
#puts "version = $version"
#puts "phase = $phase"
#puts "system = $system"
exportDiagrams "$ucgargv" "/$corporate/$project/$configuration:$version/$phase.$phase/$system.system"
# -----------------------------
# Feedback progress to the user
# -----------------------------
puts "Export finished"
}
# ugly source, should get rid of this call!!
global export_dont_run
if [catch {set export_dont_run}] {
exportMain
}