Академический Документы
Профессиональный Документы
Культура Документы
ENGLISH VERSION,
MARCH 2005
title Beginners TACL Course
MARCH 2005......................................................................................1
MARCH 2005......................................................................................1
MARCH 2005......................................................................................1
MARCH 2005......................................................................................1
MARCH 2005......................................................................................1
MARCH 2005......................................................................................1
MARCH 2005......................................................................................1
MARCH 2005......................................................................................1
1. INTRODUCTION..........................................................................1
1.1 . General.......................................................................................1
2. TACL................................................................................................2
2.1 style & Standards........................................................................2
2.2 . TACL Variables........................................................................2
2.2.1 . Aliases ................................................................................3
2.2.2 . text.......................................................................................3
2.2.3 . Macro’s...............................................................................3
2.2.4 . Routine’s.............................................................................4
2.2.5 . Struct’s................................................................................5
2.2.6 . Def’s....................................................................................6
1.1 . General
The high level language TACL (Tandem’s Advanced Command Language)
is a Command Line Interpreter (CLI). It is interpreted code and therefore
fairly expensive in processor time compared to compiled code.
This is just a basic course. After this course you can use the 2 TACL
manuals :-
TACL Reference Manual
TACL Programming Guide
In order to use this manual you must have Basic Tandem knowledge, the
more the better.
R TACL Cursus 1
English Version
2. TACL
?TACL ROUTINE
#SET #INFORMAT TACL
#SET #OUTFORMAT PRETTY
R TACL Cursus 2
English Version
2.2.1 . Aliases
These are the simplest TACL variables. They are useful for shortcuts.
?SECTION t ALIAS
tedit
2.2.2 . text
These are the default variables commonly used to hold values e.g.
#PUSH name == make a variable
#SET name Dean == give the variable a value
#OUTPUT My name is [name] == show on the screen
#POP name == remove the variable
All #xxxx command's are codes of the Guardian operating system and
written in TAL or C. Many of this commands are comparable with COBOL
system calls.
2.2.3 . Macro’s
Macro's and routines are the programming language of TACL. They can
exist independently in a file (with ?TACL MACRO as 1st row) or in a library
file with other macro’s and routines. There is no error handling possible in
a macro.
?SECTION t MACRO
#OUPUT Tediting %1%.
TEDIT %1% %2% == %1% and %2% are parameters
Macro’s are simple and quick to make and are very useful for small pieces
of code. As they become bigger, they become more difficult to read (who
knows what %9% means after 100 rows of code?) and slower because
TACL a macro must be read twice read because the parameters have to
be filled in first before execution can take place.
R TACL Cursus 3
English Version
2.2.4 . Routine’s
Routine's are more complex than macro’s but give more functionality:
1) You can write your own error handling.
2) You can control the parameters.
3) you can return a value back to the calling
routine/macro.
4) you can a exit a routine whenever you want.
?SECTION T ROUTINE
#FRAME
#PUSH filename type
#SET type [#ARGUMENT / VALUE filename / FILENAME WORD]
[#CASE [type]
|1| [#IF [#FILEINFO / OPENNOW / [filename]] |then|
#OUTPUT Sorry guy! [filename] is already open
|else|
[#IF [#FILEINFO /CODE/[filename]] = 101 |then|
tedit [filename] A [#REST]
|else|
#OUTPUT Sorry guy! [filename] is not an edit file
]
]
|2|
[#IF [#match [#INPUT [filename] exists not, create?] Y] |then|
tedit [filename] !
]
]
#UNFRAME
R TACL Cursus 4
English Version
(hopefully more meaningful!) error messages.
There are very many possibilities after the “/’. Look in the “TACL
REFERENCE MANUAL”, I've only shown a couple here
Very many Guardian routines give a value back. #ARGUMENT returns the
number of the appropriate type. In the example you get the value 1 as
the parameter is a filename and the value 2 if the argument is a word.
4) #CASE is similar to evaluate in COBOL85. An
alternative is:
#IF type = 1 |THEN| ........ |ELSE| .......
5) [#FILEINFO /OPENNOW /[FILENAME]] and
[#IF [#FILEINFO /CODE/[FILENAME]] = 101
are also very interesting. With the 1st command ask you Guardian of the
file [filename] is open. Guardian responds with true (value -1 non-null-
value) or not true (value 0). This is easy to test with #IF. The 2nd
command doesn't return a true/not true value, but the filecode of the file.
6) #INPUT waits for input from of the user and
gives as value the input. e.g. #SET filename [#INPUT ...]
7) #MATCH can you use to compare 2 strings.
The value returned is 0 (strings are different) or -1 (strings are the same).
The difference between a TACL routine and a TACL macro is that a routine
is parsed just once and a macro twice. Thus it is better to make your
TACLCSTM file a ROUTINE than a macro.
2.2.5 . Struct’s
This are TACL ‘records’. You can make TACL records with DDL (Data
Dictionary Language). This happens in the same way as with COBOL. Thus
if you have DDL source, can you quickly create TACL struct's e.g. :
1 ?TACL
Output source for TACL is opened on $ZTN0.#WIN0027
2 output def p10559.
Loading Definition P10559
== SCHEMA PRODUCED DATE - TIME : 5/18/90 14:49:49
== Definition P10559 version 1 updated on 05/01/90 at 15:55
== NE05Z00A
?Section P10559 Struct
Begin
== Function-CODE
INT E41330;
== GUARDIAN NUMBER-FILENAME
INT E41331;
== MESSAGE-NUMBER
INT E41332;
== CODE-PROGRAM-RPCN
STRUCT E41333;
BEGIN CHAR BYTE(0:9); END;
== PROGRAM data
== ABEND-indicator
R TACL Cursus 5
English Version
CHAR E41342;
End;
TACL output produced for P10559.
See the TACL manual for a description. See also paragraph 2.2.4. over
TACL & Netbatch for the _completion struct.
2.2.6 . Def’s
#OUTPUT [#TIMESTAMP]
#OUTPUT [#CONTIME [#TIMESTAMP] ]
#OUTPUT [_CONTIME_TO_TEXT_DATE [#CONTIME [#TIMESTAMP]]]
gives ….
70670204971
1997 5 23 10 7 58 20
May 23, 1997
2.2.7 . Directories
You can organise all TACL-variables in directories. You can compare them
with directories on the PC. The difference between directories and
volumes.subvolumes is, that directories stay in memory and
volumes.subvolumes are on disk. On the Tandem you use
#PMSEARCHLIST in order to tell Guardian where to search for programs
and #USELIST for your TACL variables: e.g.
#PMSEARCHLIST
#USELIST
ENV
R TACL Cursus 6
English Version
Question: What happens?
SEGINFO is useful to tell you what segments you have attached and some
details about them.
Seginfo……
Pgs Pgs Bytes Bytes
Segment File Access Now Max Now Max % UC Directory
$datf.#0008763 pr 24 1024 27332 2097152 1 11 :
$system.sys02.taclsegf sh 208 1024 420308 2097152 20 3 :utils.1
$dats.ne00ytcl.interseg sh 112 1024 226700 2097152 10 1
:internet.1
$datf.dean.deanseg sh 332 1024 667960 2097152 31 1
:deanseg.1
$datf.dean.DEANseg sh 616 1024 1257072 2097152 59 1
:DEANseg.1
$datf.dean.DEANseg2 sh 716 1024 1459540 2097152 69 1
:DEANseg2.1
As you the name of a variable type in, then TACL searches first in the
current directory and after that in every other directory in the #USELIST.
You can type “VARINFO <macro name>“ to see summary info of a
macro/routine/text variable e.g.
VARINFO volume
You can see the content of a macro with of OUTVAR e.g.
OUTVAR volume
OUTVAR OUTVAR
exercise : Try but the above 3 TACL command’s.
#PUSH x y z
#SETMANY x y z,1 2 3 == multiple of #SET
#PUSH y z
#OUTPUT [x] [y] [z]
Then get you 1 on the screen because the 2 newest versions of y and z
are empty. You can still see and use the old values :-
R TACL Cursus 7
English Version
#OUTPUT [x.1] [y.1] [z.1]
Question: Can you #POP also use to delete old values? e.g.
#POP x.1
Answer: No, not unless it's the highest in the stack, which it isn't in this
case.
If you use LOAD <file name> without the KEEP 1 option, then make you
always a new copy on top of the old in the stack. If you do this often then
you'll start using up lots of memory!
2.3.1 . Be Nice
A user generally prefers that his environment isn't changed after a macro
has ended. Take copies of variables you plan to change e.g #DEFAULTS
(this keeps track of your current subvol). This be achieved with use of
framing & popping:
[#CASE [#EXCEPTION]
|_CALL| == normal entry point for this ROUTINE
|_BREAK| == break key handling
#OUTPUT Session
terminated because the break key was hit
#UNFRAME
#RETURN
|_ERROR| #PUSH errtxt
#ERRORTEXT /CAPTURE errtxt/
#OUTPUT Tacl generated
R TACL Cursus 8
English Version
error filtered
#OUTPUT error text contains :
#OUTPUTV ERRTXT
#UNFRAME
#RETURN
] == end of exception case
This piece code MUST be on the 1st line in a routine! Otherwise the error-
handling won't work properly!
With TACL you can quickly build up a library of routines. Make the
routines object-orientated (thus ‘black boxes’), so you can use them again
and again. Give them logical names and use #RESULT to return true or
false values if you can
R TACL Cursus 9
English Version
[#IF [#VARIABLEINFO/EXISTENCE/ vol_1] AND
[#VARIABLEINFO/EXISTENCE/ &
env_name] A
< doe here something>
]
#UNFRAME
In this example see you also again the usage of #ARGUMENT and
#RESULT.
Questions :
1. The other possibilities of #VARIABLEINFO are
in the TACL manual. What possibilities are there.
2. Write an example that #LOOP and #MORE that
uses a list of filenames to and displays them in a nicer way on the screen.
Use [#FILENAMES] as input e.g.
display_files [#FILENAMES]
3. what do #OUTFORMAT and #INFORMAT do?
why in the DBU example is #OUTFORMAT pushed?
Maybe can you guess what the 2nd command does as you (hopefully!)
know what the 1st line does. Here can you make good use of #APPEND
and #EXTRACT e.g.
?TACL ROUTINE
#FRAME
#PUSH ipm results edit^level next
fup purgedata $datf.dean.DEANTACL
EDIT /INV ipm DYNAMIC ,OUTV results,NAME, NOWAIT/
SINK [#WAIT ipm]
#SET results
R TACL Cursus 10
English Version
#SET next [#FILENAMES/MAXIMUM 1/*]
[#LOOP |WHILE| NOT [#EMPTYV next] |DO|
[#IF ([#FILEINFO/CODE/[next]] = 101) AND
([#FILEINFO/EOF/[next]] > 0) AND
(NOT [#FILEINFO /OPENNOW/[next]])
|THEN|
#OUTPUT [next]
#APPEND ipm GET [next] put $datf.dean.DEANtemp!
#APPEND ipm CB /?TACL/?SECTION [next]/ A
#APPEND ipm GET $datf.dean.DEANTACL
#APPEND ipm GET $DATF.DEAN.DEANtemp TO L
SINK [#WAIT ipm]
#OUTPUTV results
#SET results
|ELSE|
#OUTPUT Problem with [next]
fi [next]
]
#SET next [#FILENAMES/MAXIMUM 1,PREVIOUS [next]/*]
] == END LOOP
#APPEND ipm EXIT
SINK [#WAIT ipm]
#UNFRAME
Questions:
1. If you type “#WAIT ipm results”, what value do
get you back?
2. why is use made of SINK [#WAIT ipm]?
You can also use #SET #TRACE -1 to start the debugger. You can also use
#FILENAMES with the option MAXIMUM. With maximum 1 and
Previous ..... you can process the files 1 for 1 in a subvolume (See the
above example)
FILETOVAR and VARTOFILE are useful if you want to work files and don't
know EDIT very well e.g.
#PUSH file^in^memory
FILETOVAR $DATF.DEAN.TEMP file^in^memory
R TACL Cursus 11
English Version
==process file^in^memory
VARTOFILE file^in^memory $DATF.DEAN.TEMPOUT
FILETOVAR reads a file and puts the content of the file in a TACL-variable;
VARTOFILE works the other way.
LET ON! FILETOVAR and VARTOFILE are TACL (interpreted) routines. For
bigger files you can better use FUP or EDIT.
See the appendices for the content of peruse_init, DPSP (Define Process
Spoolcom etc.
PNAME is the abbreviation to talk to the Tandem utility (thus in this case
you use P instead of PERUSE)
You can, as in TACL, use/cancel history with the HISTORY/NOHISTORY
option.
INIT is a macro or routine which is run only once when you start up
PERUSE (in this case) for the 1st time. PREPARSE is very useful. You can
use it to translate your own shortcuts for commands into the full blown
commands.
2.3.6 . Debugging
#SET #TRACE -1
You can type this into the macro or routine you want to debug or type it in
at the TACL prompt and after that you type :
B <macro name>
R
<macro name>
question:
Try to debug the Tandem TACL Routine VOLUME with “#SET #TRACE -1”
and “B VOLUME”.
1. What happens then?
2. why do you think that you get an error
message?
R TACL Cursus 12
English Version
2.3.7 . TACL Segments
TACL is interpreted code (thus not compiled). The use of TACL can heavily
tax the system. You must use TACL wisely. There are 3 different ways to
execute TACL code:
With 1) loads TACL the code each time into memory. You use more disk
space as you every TACL macro is in a separate file. This is handy for
testing macros however.
With 2) everyone who loads the library has a copy of all macro’s in the
library. This is quicker but can use a lot of memory.
With 3) the macros are in shared memory so everyone can use the
macros. Further the TACL code in a segment is pre-processed/compiled
and therefore quicker. The attachment to a segment is far quicker than a
LOAD of a TACL library file. A segment object file has a file code of 440.
To use a segment do the following:
If you type in #USELIST at the TACL prompt then you see the updated
value of it :-
#USELIST
The ‘use’-command tells TACL where to look for TACL routines. If you
LOAD TACL libraries, by default the routines get loaded into your default
TACL directory and are they not usable by other people.
Macro's are slower than routines. A macro must twice read become
because TACL the %1% etc. must be replaced by the parameters. Macro's
are also less readable. Use macro's only for small pieces of code.
R TACL Cursus 13
English Version
program’s
]
|ELSE|
#OUTPUT FAILURE CONTACT SUPPORT NOW :
] == end if
Question:
What are the possible values of _completion:completioncode?
R TACL Cursus 14
English Version
3. Appendices
3.1 . create^segment
?SECTION create^segment ROUTINE
==#FRAME don't use frame because unframe will pop the segment!
[#CASE [#EXCEPTION]
|_CALL| == normal entry point for this ROUTINE
home :
#PUSH segment^name backup^name n dest_vol older^backup^name file
buffer
R TACL Cursus 15
English Version
]
R TACL Cursus 16
English Version
|OTHERWISE|
on You have chosen to create a strange new lifeform
on
on Do not use this for new environment segments as they
on must be added to the list first...see Dean
on
on At each prompt type in the name of the tacl file to load
on When you have finished, hit return with nothing entered
#SET file [#INPUT Load which file ?_]
[#LOOP |WHILE| NOT [#EMPTYV file] |DO|
LOAD/KEEP 1/[file]
#SET file [#INPUT Load which file ?_]
]
#SET dest_vol [#INPUT Which $VOL.SUBVOL do you want me to
the put segment on?]
]
DETACHSEG :TEMPSEG
#set n 9
#SET backup^name [#CHARGET segment^name 1 FOR 7]
#SET backup^name [backup^name][n]
SINK [#PURGE [dest_vol].[backup^name]]
[#LOOP |DO|
#SET older^backup^name [#CHARGET segment^name 1 FOR 7]
#SET older^backup^name [older^backup^name][n]
#SET n [#COMPUTE [n] - 1]
#SET backup^name [#CHARGET segment^name 1 FOR 7]
#SET backup^name [backup^name][n]
[#IF [#PURGE [dest_vol].[backup^name]] = 12 |THEN|
RENAME [dest_vol].[backup^name] [dest_vol].
[older^backup^name]
]
|UNTIL| [n] <= 1
]
[#IF [#PURGE [dest_vol].[segment^name]] = 12
|THEN|
RENAME [dest_vol].[segment^name] [dest_vol].[backup^name]
]
R TACL Cursus 17
English Version
3.2 . Defined Processes
?SECTION PERUSE_INIT ROUTINE
#OUTPUT Peruse no longer does a J on entry so that you now can have
access to
#OUTPUT PERUSAL! By typing # or # <command> you can pass
commands between
#OUTPUT PERUSE and SPOOLCOM.
R TACL Cursus 18
English Version
#CHARDEL in_cmd 1
P [in_cmd]
#SET :DPCOMMAND
|ELSE|
#SETMANY in_cmd, [in_cmd]
[#CASE [in_cmd]
|D* | #SET :DPCOMMAND JOB (OWNER),DELETE
|D*!| #SET :DPCOMMAND JOB (OWNER),DELETE!
|E EXIT | #LINEDEL :DPCOMMAND 1 FOR 1
#OUTPUT Please use CTRL-Y to exit. Sorry for the
inconvenience.
|OTHERWISE|
]
]
]
#UNFRAME
R TACL Cursus 19
English Version