Doc.
We use TCL translations in most of our interfaces and use ‘tables’ extensively. We use a TCL array …
proc QryTableTop {aCode} {
# make the array global, so it is always available
global QryTableTopArray
#
# if the array requires initialisation, do this now
#
if {[array exists QryTableTopArray] == 0} {
set QryTableTopArray(A) AKHS
…
set QryTableTopArray(X) 3811
set QryTableTopArray(Z) 3812
}
# set the return variable to the default value
set myData $aCode
# make sure we don’t fall over if there is NO data!
catch {set myData $QryTableTopArray($aCode)}
# return the data from the array
return $myData
}
We also have a library of common functions that we use and the library code and common functions exist in a ‘LIB’ directory, which is referenced from a site tclIndex
eg
# Tcl autoload index file, version 2.0
# This file is generated by the “auto_mkindex” command
# and sourced to set up indexing information for one or
# more commands. Typically each line is a command that
# sets an element in the auto_index array, where the
# element name is the name of a command and the value is
# a script that loads the command.
set auto_index(ccm_xlate_ris)
]
set auto_index(ccm_xlate_cap)
]
set auto_index(ccm_xlate_ult)
]
set auto_index(ccm_xlate_rad)
]
set auto_index(ccm_xlate_sud)
]
set auto_index(MakeMrn)
]
set auto_index(MakeAcct)
]
set auto_index(MakePtType)
]
set auto_index(MakeLabHospitalService)
]
set auto_index(MakeCtrlId)
]
set auto_index(MapHexChars)
]
set auto_index(TranEncChars)
]
…
set auto_index(gen_code_resend)
]
set auto_index(gen_code_printmsg)
]
set auto_index(gen_code_splitter)
]
set auto_index(gen_code_mkreply)
]
set auto_index(Print)
]
set auto_index(RetRepeat)
]
set auto_index(RetComp)
]
set auto_index(ChangeField)
]
set auto_index(SourceTablesFile)
]
We run on Unix, so we use ‘make’ and CVS to create the TCL files and tclIndex. We also use Unix links to keep one copy of the source and provide a simple method of managing code changes.