Lesson 6
Linux / Apache / GT.M / Web Application Lesson 6
Indirection - A complex concept, used in a simple example.
The following routine makes use of the D(o) command to perform functions that draw each type table.
The do command is used to run a function and routine operation continues with the next command after the calling D(o) command.
The function "done" starts at the program tag called by the D(o) command and continues until the Q(uit) command, at which point operation returns to the command just after the calling D(o) command.
In the routine for this lession the command "D TB1" causes execution to go to the routine tag "TB1" and perform the operations in this function down to the point of the Q(uit) command, then execution returns to the command "S XX="TB1"".
The next topic, Indirection, allows the programmer to set a variable equal to a program tag. When used with the command "D @XX" execution goes to the routine tag that is the value contained in XX.
So the two commands in this case actually are the same and you will notice on your web page that each table is drawn twice.
The command line "D TB1" and "S XX="TB1" D @XX" perform the same function.
This looks a little silly at this point, but it's use will become very useful in the following lessons.
ZZLIB6
ZZLIB6 ; ROUTINE TO CREATE A WEB PAGE USING THE ^ZZLIB3 GLOBAL.
;
;
W "Content-type: text/html",!!
W "<html>",!
W "<head>",!
W "<title>ZZLIB3 GLOBAL LISTS.</title>",!
W "</head>",!
W "<body>",!
;
D TB1
S XX="TB1"
D @XX
;
D TB2
S XX="TB2"
D @XX
;
D TB3
S XX="TB3"
D @XX
;
W "</body>",!
W "</html>",!
;
Q
;TB1 W "
",! W "
INDEX | FIRST NAME | LAST NAME | ",! W "
---|---|---|
",ZS1," | ","",$P(ZD1,"^",2)," | ","",$P(ZD1,"^",1)," | ",! .W "
Q
;TB2 W "
",! W "
INDEX | FIRST NAME | LAST NAME | ",! W "
---|---|---|
",ZS4," | ","",$P(ZD4,"^",2)," | ","",$P(ZD4,"^",1)," | ",! ...W "
Q
TB3 ;
W "",! W "
INDEX | FIRST NAME | LAST NAME | ",! W "
---|---|---|
",ZS4," | ","",$P(ZD4,"^",2)," | ","",$P(ZD4,"^",1)," | ",! ...W "
Q