home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # Copyright (c) 1992-1997 by Cayenne Software, Inc.
- #
- # This software is furnished under a license and may be used only in
- # accordance with the terms of such license and with the inclusion of
- # the above copyright notice. This software or any other copies thereof
- # may not be provided or otherwise made available to any other person.
- # No title to and ownership of the software is hereby transferred.
- #
- # The information in this software is subject to change without notice
- # and should not be construed as a commitment by Cadre Technologies Inc.
- #
- #---------------------------------------------------------------------------
- #
- # File : @(#)caynutil.tcl /main/hindenburg/2
- # Original date : Wed Aug 5 12:04:46 MET DST 1992
- # Description : Cayenne TCL utilities
- # Basic utilities, should not use TCL procs defined
- # in other files !!!
- #
- #---------------------------------------------------------------------------
- #
- # @(#)caynutil.tcl /main/hindenburg/2 27 May 1997 Copyright 1992-1997 Cayenne Software, Inc.
- #
- #---------------------------------------------------------------------------
-
- require cayn_msg.tcl
-
- #
- # Procedure to reset the result to ""
- #
-
- proc null {} {}
-
- #
- # The Unix date command implemented in Tcl
- #
-
- proc date {} {
- return [fmtclock [getclock]]
- }
-
- #
- # Return the name part of name.type
- #
-
- proc nt_get_name {name} {
- regsub {\.[^.]*$} $name "" name
- return $name
- }
-
- #
- # Return the type part of name.type
- #
-
- proc nt_get_type {fullname} {
- if {[regsub {.*\.} $fullname "" type]} {
- return [get type]
- }
- return ""
- }
-
- #
- # Print the contents of variable s on the standard output stream
- #
-
- proc echo {s} {
- puts stdout $s
- }
-
- #
- # Print the contents of errorInfo on the standard output stream
- #
-
- proc perror {} {
- echo $errorInfo
- }
-
- #
- # Read the contents from a file into a Tcl string
- #
-
- proc read_file_into_text {path text} {
- upvar $text txt
-
- if {![file exists $path]} {
- m4_error $E_EXIST_FILE $path
- return 0
- }
-
- set fd [open $path "r"]
- set txt [read $fd]
- close $fd
- return 1
- }
-
- #
- # capitalize the first letter of a string
- #
-
- proc cap {str} {
- set ch [string toupper [string index $str 0]]
- return "$ch[string range $str 1 end]"
- }
-
- #
- # uncapitalize the first letter of a string
- #
-
- proc uncap {str} {
- set ch [string tolower [string index $str 0]]
- return "$ch[string range $str 1 end]"
- }
-
- #
- # Copy a file
- #
-
- proc copy_text_file {from to} {
- set max 8092
- set in [open $from r]
- set out [open $to w]
-
- while {[set result [read $in $max]] != ""} {
- puts $out $result nonewline
- }
-
- close $in
- close $out
- }
-
- #
- # Function to show proc invocations, activated using option "-trace"
- #
-
- proc trace_call {call obj args} {
- global tracing
-
- if {$tracing == 1} {
- puts -nonewline " >>> [$obj get_obj_type]::$call '"
-
- if [catch {puts -nonewline "[$obj getName]"}] {
- puts -nonewline "<unnamed>"
- }
-
- puts "' $args"
- }
- }
-
- #
- # Append one or more strings to the given list only if it was not
- # already present. Has exactly the same calling interface as the builtin
- # 'lappend'.
- #
- # Returns the new list
- #
-
- proc lappend_unique {l args} {
- upvar $l list
-
- foreach s $args {
- if {[lsearch -exact $list $s] == -1} {
- lappend list $s
- }
- }
-
- return $list
- }
-
-