Difference between revisions of "Lesson 5"
(Added glossary link to Application~) |
|||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
− | Linux / Apache / GT.M / Web Application Lesson 5 | + | Linux / Apache / GT.M / Web [[Application~|Application]] Lesson 5 |
− | By Ben | + | By Ben Irwin, |
Copied from: http://www.doggiedudes.com/fscc/list.htm | Copied from: http://www.doggiedudes.com/fscc/list.htm | ||
Latest revision as of 14:35, 22 February 2012
Linux / Apache / GT.M / Web Application Lesson 5
By Ben Irwin, Copied from: http://www.doggiedudes.com/fscc/list.htm
Tutorial Home: M Web Tutorials Prev: Lesson 4 Next: Lesson 6
In Lesson 5 we are going use the global ^ZZLIB3 that we produced in lesson 4 to create three web tables. Table 1 will list the names by index number, Table 2 will list the names by last name, Table 3 will list the names by first name.
I realize that this is a touchy situation but I have again listed the cgi script that I used to make this work. Please use one similar to one that you have already working, only change the routine to ZZLIB5, if that is what you chose to name your routine for this lesson.
library.sh5 ------------------------------------------------------------------------- #!/bin/sh cd /usr/local/gtm/VISTA export gtm_dist=/usr/local/gtm export gtmroutines="$gtm_dist/VISTA/uo($gtm_dist/VISTA/ur) $gtm_dist" export gtmgbldir=/usr/local/gtm/VISTA/mumps.gld export PATH=$PATH:$gtm_dist mumps -run ZZLIB5 -------------------------------------------------------------------------
The global that I used is the ^ZZLIB3 global as shown below.
^ZZLIB3 ------------------------------------------------------------------------- ^ZZLIB3(0)="4^4" ^ZZLIB3(1)="IRWIN^BENJAMIN" ^ZZLIB3(2)="FLINTSTONE^FRED" ^ZZLIB3(3)="JETSON^GEORGE" ^ZZLIB3(4)="FLINTSTONE^FRED" ^ZZLIB3("B","FLINTSTONE","FRED",2)="" ^ZZLIB3("B","FLINTSTONE","FRED",4)="" ^ZZLIB3("B","IRWIN","BENJAMIN",1)="" ^ZZLIB3("B","JETSON","GEORGE",3)="" ^ZZLIB3("C","BENJAMIN","IRWIN",1)="" ^ZZLIB3("C","FRED","FLINTSTONE",2)="" ^ZZLIB3("C","FRED","FLINTSTONE",4)="" ^ZZLIB3("C","GEORGE","JETSON",3)="" -------------------------------------------------------------------------
The routine that I used to produce the web table follows.
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.
ZZLIB5 ------------------------------------------------------------------------- ZZLIB5 ; 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>",! 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>","<TD>",$P(ZD1,"^",1),"</TD>",! .W "</TR>",! W "</TABLE>",! W "</P>",! ; 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>",! ; 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>",! ; W "</body>",! W "</html>",! ; Q
-------------------------------------------------------------------------
I called it by entering the following line into the web browser.
------------------------------------------------------------------------- http://10.0.1.209/cgi-bin/library.sh5 -------------------------------------------------------------------------
The following is an explanation of the process.
Almost every opening web tag requires a closing web tag. The paragraph tag {P} is an exception, but I used a closing tag here just to make my routine look good.
Each table section starts with a new paragraph tag {P}, and ends with a end paragraph tag {/P}.
Each table starts with a table tag {TABLE}, and ends with a table end tag {/TABLE}. In this case I requested a table border of 1 to surround my cells. You can play with that number and watch what it does.
I placed headers at the top of the table using the start table row tag {TR} and ended the header section with a end table row tag (/TR}.
Within the table row tags, I identified each table header by a start table header tag {TH} and a end table header tag {/TH}.
The next section I start moving through the mumps global using the $O function. For the names listed by index number, table 1, I start by setting ZS1=0. Within the F(or) loop I use the $O function to move the value of ZS1 to the value in the global just after the previous value. The first time through the loop that would now make ZS1=1.
Then I place the data that is at ^ZZLIB3(1) equal to ZD1. I use the numeric value of ZS1, in the first loop that would be the number 1, and write it between table data tags, {TD} and {/TD}.
Then I use the $P(iece) function to get the second piece of data from ZD1, first name, and place it between table data tags, {TD} and {/TD}.
Then I use the $P(iece) function to get the first piece of data from ZD1, last name and place it between table data tags, {TD} and {/TD}.
The second table goes through the same process, just a deeper array structure that is sorted by last name. The "B" cross reference.
The third table again goes through the process using the "C" cross reference, in this case sorted by first name.
Tutorial Home: M Web Tutorials Prev: Lesson 4 Next: Lesson 6