Difference between revisions of "Lesson 6"

From VistApedia
Jump to: navigation, search
(Added glossary link to Application~)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Linux / Apache / GT.M / Web Application Lesson 6
+
Linux / Apache / GT.M / Web [[Application~|Application]] Lesson 6
 +
 +
By Ben Irwin,
 +
Copied from: http://www.doggiedudes.com/fscc/list.htm
  
  Tutorial Home: [[M2Web Tutorials]]
+
  Tutorial Home: [[M Web Tutorials]]
 
  Prev: [[Lesson 5]]
 
  Prev: [[Lesson 5]]
 
  Next: [[Lesson 7]]
 
  Next: [[Lesson 7]]
Line 23: Line 26:
 
This looks a little silly at this point, but it's use will become very useful in the following lessons.
 
This looks a little silly at this point, but it's use will become very useful in the following lessons.
  
IMPORTANT NOTICE: ALL OF THE '<' CHARACTERS HAVE BEEN REPLACED BY '{' CHARACTERS BECAUSE THE WIKI WAS NOT FORMATTING PROPERLY OTHERWISE. LIKEWISE, ALL THE '>' WERE CHANGED TO '}'. Replace these back to the proper '<' and '>' characters when typing into your system.
+
IMPORTANT NOTICE: ALL OF THE '<' CHARACTERS HAVE BEEN REPLACED BY the HTML entity CHARACTERS ie: & lt ; BECAUSE THE WIKI WAS NOT FORMATTING PROPERLY OTHERWISE. LIKEWISE, ALL THE '>' characters WERE CHANGED TO & rt ; . You can cut and paste from the rendered page, but you will have to Replace these back to the proper '<' and '>' characters when cutting and pasting from the edit-page.
  
ZZLIB6
+
<pre>
 +
ZZLIB6
 
   
 
   
 
  -------------------------------------------------------------------------------
 
  -------------------------------------------------------------------------------
Line 33: Line 37:
 
     ;
 
     ;
 
     W "Content-type: text/html",!!
 
     W "Content-type: text/html",!!
     W "{html}",!
+
     W "&lt;html&gt;",!
     W "{head}",!
+
     W "&lt;head&gt;",!
     W "{title}ZZLIB3 GLOBAL LISTS.{/title}",!
+
     W "&lt;title&gt;ZZLIB3 GLOBAL LISTS.&lt;/title&gt;",!
     W "{/head}",!
+
     W "&lt;/head&gt;",!
     W "{body}",!
+
     W "&lt;body&gt;",!
 
     ;
 
     ;
 
     D TB1
 
     D TB1
Line 51: Line 55:
 
     D @XX
 
     D @XX
 
     ;
 
     ;
     W "{/body}",!
+
     W "&lt;/body&gt;",!
     W "{/html}",!
+
     W "&lt;/html&gt;",!
 
     ;
 
     ;
 
     Q
 
     Q
 
     ;
 
     ;
  TB1 W "{P}",!
+
  TB1 W "&lt;P&gt;",!
     W "{TABLE BORDER=1}",!
+
     W "&lt;TABLE BORDER=1&gt;",!
     W "{TR}",!
+
     W "&lt;TR&gt;",!
     W "{TH}INDEX{/TH}{TH}FIRST NAME{/TH}{TH}LAST NAME{/TH}",!
+
     W "&lt;TH&gt;INDEX&lt;/TH&gt;&lt;TH&gt;FIRST NAME&lt;/TH&gt;&lt;TH&gt;LAST NAME&lt;/TH&gt;",!
     W "{/TR}",!
+
     W "&lt;/TR&gt;",!
 
     S ZS1=0
 
     S ZS1=0
 
     F  S ZS1=$O(^ZZLIB3(ZS1)) Q:+ZS1=0  D
 
     F  S ZS1=$O(^ZZLIB3(ZS1)) Q:+ZS1=0  D
 
     .S ZD1=^ZZLIB3(ZS1)
 
     .S ZD1=^ZZLIB3(ZS1)
     .W "{TR}",!
+
     .W "&lt;TR&gt;",!
     .W "{TD}",ZS1,"{/TD}","{TD}",$P(ZD1,"^",2),"{/TD}"
+
     .W "&lt;TD&gt;",ZS1,"&lt;/TD&gt;","&lt;TD&gt;",$P(ZD1,"^",2),"&lt;/TD&gt;"
     .W "{TD}",$P(ZD1,"^",1),"{/TD}",!
+
     .W "&lt;TD&gt;",$P(ZD1,"^",1),"&lt;/TD&gt;",!
     .W "{/TR}",!
+
     .W "&lt;/TR&gt;",!
     W "{/TABLE}",!
+
     W "&lt;/TABLE&gt;",!
     W "{/P}",!
+
     W "&lt;/P&gt;",!
 
     Q
 
     Q
 
     ;
 
     ;
  TB2 W "{P}",!
+
  TB2 W "&lt;P&gt;",!
     W "{TABLE BORDER=1}",!
+
     W "&lt;TABLE BORDER=1&gt;",!
     W "{TR}",!
+
     W "&lt;TR&gt;",!
     W "{TH}INDEX{/TH}{TH}FIRST NAME{/TH}{TH}LAST NAME{/TH}",!
+
     W "&lt;TH&gt;INDEX&lt;/TH&gt;&lt;TH&gt;FIRST NAME&lt;/TH&gt;&lt;TH&gt;LAST NAME&lt;/TH&gt;",!
     W "{/TR}",!
+
     W "&lt;/TR&gt;",!
 
     S ZS1="B"
 
     S ZS1="B"
 
     S ZS2=""
 
     S ZS2=""
Line 85: Line 89:
 
     ..F  S ZS4=$O(^ZZLIB3(ZS1,ZS2,ZS3,ZS4)) Q:ZS4=""  D
 
     ..F  S ZS4=$O(^ZZLIB3(ZS1,ZS2,ZS3,ZS4)) Q:ZS4=""  D
 
     ...S ZD4=^ZZLIB3(ZS4)
 
     ...S ZD4=^ZZLIB3(ZS4)
     ...W "{TR}",!
+
     ...W "&lt;TR&gt;",!
     ...W "{TD}",ZS4,"{/TD}","{TD}",$P(ZD4,"^",2),"{/TD}"
+
     ...W "&lt;TD&gt;",ZS4,"&lt;/TD&gt;","&lt;TD&gt;",$P(ZD4,"^",2),"&lt;/TD&gt;"
     ...W "{TD}",$P(ZD4,"^",1),"{/TD}",!
+
     ...W "&lt;TD&gt;",$P(ZD4,"^",1),"&lt;/TD&gt;",!
     ...W "{/TR}",!
+
     ...W "&lt;/TR&gt;",!
     W "{/TABLE}",!
+
     W "&lt;/TABLE&gt;",!
     W "{/P}",!
+
     W "&lt;/P&gt;",!
 
     Q
 
     Q
 
  TB3 ;
 
  TB3 ;
     W "{P}",!
+
     W "&lt;P&gt;",!
     W "{TABLE BORDER=1}",!
+
     W "&lt;TABLE BORDER=1&gt;",!
     W "{TR}",!
+
     W "&lt;TR&gt;",!
     W "{TH}INDEX{/TH}{TH}FIRST NAME{/TH}{TH}LAST NAME{/TH}",!
+
     W "&lt;TH&gt;INDEX&lt;/TH&gt;&lt;TH&gt;FIRST NAME&lt;/TH&gt;&lt;TH&gt;LAST NAME&lt;/TH&gt;",!
     W "{/TR}",!
+
     W "&lt;/TR&gt;",!
 
     S ZS1="C"
 
     S ZS1="C"
 
     S ZS2=""
 
     S ZS2=""
Line 106: Line 110:
 
     ..F  S ZS4=$O(^ZZLIB3(ZS1,ZS2,ZS3,ZS4)) Q:ZS4=""  D
 
     ..F  S ZS4=$O(^ZZLIB3(ZS1,ZS2,ZS3,ZS4)) Q:ZS4=""  D
 
     ...S ZD4=^ZZLIB3(ZS4)
 
     ...S ZD4=^ZZLIB3(ZS4)
     ...W "{TR}",!
+
     ...W "&lt;TR&gt;",!
     ...W "{TD}",ZS4,"{/TD}","{TD}",$P(ZD4,"^",2),"{/TD}"
+
     ...W "&lt;TD&gt;",ZS4,"&lt;/TD&gt;","&lt;TD&gt;",$P(ZD4,"^",2),"&lt;/TD&gt;"
     ...W "{TD}",$P(ZD4,"^",1),"{/TD}",!
+
     ...W "&lt;TD&gt;",$P(ZD4,"^",1),"&lt;/TD&gt;",!
     ...W "{/TR}",!
+
     ...W "&lt;/TR&gt;",!
     W "{/TABLE}",!
+
     W "&lt;/TABLE&gt;",!
     W "{/P}",!
+
     W "&lt;/P&gt;",!
 
     Q
 
     Q
  
  Tutorial Home: [[M2Web Tutorials]]
+
</pre>
 +
 
 +
  Tutorial Home: [[M Web Tutorials]]
 
  Prev: [[Lesson 5]]
 
  Prev: [[Lesson 5]]
 
  Next: [[Lesson 7]]
 
  Next: [[Lesson 7]]

Latest revision as of 14:36, 22 February 2012

Linux / Apache / GT.M / Web Application Lesson 6

By Ben Irwin, 
Copied from: http://www.doggiedudes.com/fscc/list.htm
Tutorial Home: M Web Tutorials
Prev: Lesson 5
Next: Lesson 7

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.

IMPORTANT NOTICE: ALL OF THE '<' CHARACTERS HAVE BEEN REPLACED BY the HTML entity CHARACTERS ie: & lt ; BECAUSE THE WIKI WAS NOT FORMATTING PROPERLY OTHERWISE. LIKEWISE, ALL THE '>' characters WERE CHANGED TO & rt ; . You can cut and paste from the rendered page, but you will have to Replace these back to the proper '<' and '>' characters when cutting and pasting from the edit-page.

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 "<P>",!
     W "<TABLE BORDER=1>",!
     W "<TR>",!
     W "<TH>INDEX</TH><TH>FIRST NAME</TH><TH>LAST NAME</TH>",!
     W "</TR>",!
     S ZS1=0
     F  S ZS1=$O(^ZZLIB3(ZS1)) Q:+ZS1=0  D
     .S ZD1=^ZZLIB3(ZS1)
     .W "<TR>",!
     .W "<TD>",ZS1,"</TD>","<TD>",$P(ZD1,"^",2),"</TD>"
     .W "<TD>",$P(ZD1,"^",1),"</TD>",!
     .W "</TR>",!
     W "</TABLE>",!
     W "</P>",!
     Q
     ;
 TB2 W "<P>",!
     W "<TABLE BORDER=1>",!
     W "<TR>",!
     W "<TH>INDEX</TH><TH>FIRST NAME</TH><TH>LAST NAME</TH>",!
     W "</TR>",!
     S ZS1="B"
     S ZS2=""
     F  S ZS2=$O(^ZZLIB3(ZS1,ZS2)) Q:ZS2=""  D
     .S ZS3=""
     .F  S ZS3=$O(^ZZLIB3(ZS1,ZS2,ZS3)) Q:ZS3=""  D
     ..S ZS4=""
     ..F  S ZS4=$O(^ZZLIB3(ZS1,ZS2,ZS3,ZS4)) Q:ZS4=""  D
     ...S ZD4=^ZZLIB3(ZS4)
     ...W "<TR>",!
     ...W "<TD>",ZS4,"</TD>","<TD>",$P(ZD4,"^",2),"</TD>"
     ...W "<TD>",$P(ZD4,"^",1),"</TD>",!
     ...W "</TR>",!
     W "</TABLE>",!
     W "</P>",!
     Q
 TB3 ;
     W "<P>",!
     W "<TABLE BORDER=1>",!
     W "<TR>",!
     W "<TH>INDEX</TH><TH>FIRST NAME</TH><TH>LAST NAME</TH>",!
     W "</TR>",!
     S ZS1="C"
     S ZS2=""
     F  S ZS2=$O(^ZZLIB3(ZS1,ZS2)) Q:ZS2=""  D
     .S ZS3=""
     .F  S ZS3=$O(^ZZLIB3(ZS1,ZS2,ZS3)) Q:ZS3=""  D
     ..S ZS4=""
     ..F  S ZS4=$O(^ZZLIB3(ZS1,ZS2,ZS3,ZS4)) Q:ZS4=""  D
     ...S ZD4=^ZZLIB3(ZS4)
     ...W "<TR>",!
     ...W "<TD>",ZS4,"</TD>","<TD>",$P(ZD4,"^",2),"</TD>"
     ...W "<TD>",$P(ZD4,"^",1),"</TD>",!
     ...W "</TR>",!
     W "</TABLE>",!
     W "</P>",!
     Q

Tutorial Home: M Web Tutorials
Prev: Lesson 5
Next: Lesson 7