Previous: Porting Fortran Up: VICAR Porting Guide Next: Mixing Fortran and C

Porting TCL

TCL procedure PDFs must be portable as well. TCL is the TAE Command Language, used to write most VICAR procedures. Although it is designed to be fairly portable, in that the commands are the same for any version of TAE, there are some things you need to watch out for.

The most significant thing that will have to be changed is use of the dcl command inside a procedure. This command allows you to put VMS DCL commands in your procedure, which are, of course, not portable. The corresponding command under Unix is ush, which allows you to execute shell commands inside the procedure.

In order to use the dcl or ush commands, there has to be some way of determining which operating system you are on. Fortunately, there is a global variable called ``$syschar'' that holds the type of operating system. Index 1 in this variable is either ``UNIX'' or ``VAX_VMS''. For example:

parm file string
refgbl $syschar
if ($syschar(1) = "UNIX")
  ush rm &file
  dcl delete &file

Unfortunately, there appears to be no straightforward way to determine the particular version of Unix, so stick to common shell commands.

Another major trouble area for porting TCL is filenames. Filenames and pathnames look much different under VMS and Unix. There is a lot of TCL code in VICAR that parses filenames, appends filenames to directories, etc. Many test scripts use hardcoded VMS directories and filenames to find test files. All of these will have to change. The same ``$syschar'' variable can be used to do different things with the filename, or pick different test files, based on which system you are using.

The ``$syschar'' variable may also be tested inside help files, help within a PDF, and menus via special conditional commands. These commands are part of TAE, but they are unfortunately not documented by TAE. The conditionals all test to see if the given string is in any element of the ``$syschar'' variable. Like other PDF/MDF directives, they should appear on a line by themselves with the ``.'' in the first column.

For example, the following lines are taken from the TAE command mode help file (commode.hlp):

CONT*INUE .if VAX_VMS DCL any-VMS/DCL-command DCL-NOINTERRUPT any-VMS/DCL-command .ifend DEFC*MD COMMAND=command-name STRING=replacement-string


T*UTOR-NOSCREEN PROC=proc-subcmd parameters .if1 UNIX USH any-UNIX/shell-command WAIT-ASYNC JOB=job-name-list


RUNTYPE Command Qualifier (continued)

If the command qualifier is set to BATCH, the following TAE message is displayed:

.if VAX_VMS Job (nnn) submitted to queue (que)

where "nnn" is the assigned job number and "que" is the name of the queue the job was submitted to.

.elseif UNIX Batch job file "filename" submitted successfully.

where "filename" is the batch job file name, defined as "proc".job.


You should refer to the TAE documentation if you have more questions on writing portable TCL.