Difference between revisions of "Lesson 4"
Line 1: | Line 1: | ||
Linux / Apache / GT.M / Web Application Lesson 4 | Linux / Apache / GT.M / Web Application Lesson 4 | ||
+ | |||
+ | By Ben Irvin, | ||
+ | Copied from: http://www.doggiedudes.com/fscc/list.htm | ||
Tutorial Home: [[M Web Tutorials]] | Tutorial Home: [[M Web Tutorials]] |
Revision as of 21:24, 10 October 2006
Linux / Apache / GT.M / Web Application Lesson 4
By Ben Irvin, Copied from: http://www.doggiedudes.com/fscc/list.htm
Tutorial Home: M Web Tutorials Prev: Lesson 3 Next: Lesson 5
In Lesson 4 we are going to leave the cgi scripts and html behind and talk about how FileMan, the database portion of VISTA stores data.
There are two general choices in database creation.
The first option would be to just store data in an unsorted list, and sort the data as needed. This option saves disk space, and speeds data entry (no millisecond pause after the enter key is pressed). However, the time to produce reports and look up information look up is greatly increased.
The second option is to store data in a list with an index number, and create indexes at the time of data entry. This takes up more disk space, and takes a little longer when the enter key is pressed (maybe a millisecond).
VISTA with the help of FileMan uses the second option. We are going to create a short mumps routine to "simulate" a very small Fileman database.
The following internally documented routine builds our global. I am sorry for any word wrapping. It is hard to avoid.
ZZLIB3 ---------------------------------------------------------------- ZZLIB3 ; ROUTINE TO CREATE A SIMULATED FILEMAN GLOBAL. ; ; Write a line asking the user to input name. RS W !,"PLEASE INPUT NAME (LASTNAME,FIRSTNAME): " ; ; Accept (read) user input and place the value into LNFN. R LNFN ; ; End the routine if the user only presses the enter key. G:LNFN="" END ; ; Increment counter one. S $P(^ZZLIB3(0),"^",1)=$P($G(^ZZLIB3(0)),"^",1)+1 ; ; Increment counter two. S $P(^ZZLIB3(0),"^",2)=$P($G(^ZZLIB3(0)),"^",2)+1 ; ; Set the data in the global at the counter two value. S ^ZZLIB3($P(^ZZLIB3(0),"^",2))=$P(LNFN,",",1)_"^"_$P(LNFN,",",2) ; ; Set the "B" index into a global array by ; Lastname,Firstname,Counter Two. S ^ZZLIB3("B",$P(LNFN,",",1),$P(LNFN,",",2),$P(^ZZLIB3(0),"^",2))="" ; ; Set the "C" index into a global array by ; Firstname,Lastname,Counter Two. S ^ZZLIB3("C",$P(LNFN,",",2),$P(LNFN,",",1),$P(^ZZLIB3(0),"^",2))="" ; ; Repeat the process. G RS ; END ; END OF ROUTINE ; Q
After entering the routine, I used the following names to build the global.
GTM>D ^ZZLIB3 PLEASE INPUT NAME (LASTNAME,FIRSTNAME): IRWIN,BENJAMIN PLEASE INPUT NAME (LASTNAME,FIRSTNAME): FLINTSTONE,FRED
PLEASE INPUT NAME (LASTNAME,FIRSTNAME): JETSON,GEORGE PLEASE INPUT NAME (LASTNAME,FIRSTNAME): FLINTSTONE,FRED
PLEASE INPUT NAME (LASTNAME,FIRSTNAME):
GTM>
Then I used the %GO routine to view the global structure.
GTM>D ^%GO
Global Output Utility
Global ^ZZLIB3
^ZZLIB3
Current total of 1 global.
Global ^
Header Label:
Output Format: GO or ZWR:
Output device: <terminal>:
%GO Global Output Utility GT.M 25-AUG-2003 19:46:32 ZWR ^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)="" Total of 13 nodes in 1 global.
GTM>
This shows the ^ZZLIB3 global with the data in nodes 1, 2, 3, 4.
The index node "B" has additional array indexes to sort by last name, then first name, and then by the data index number. This allows multiple "Fred Flinstones" to exist in the same database.
The index node "C" has additional array indexes to sort by first name, then last name, and then by the data index number.
The two values at node 0 (zero) are used by FileMan to determine how many names are in the database and the next number to assign.
I am sorry I can't remember which one is which for sure. If a name is deleted from the database then one number would be decreased by one, but the data index number would remain unchanged and would increment after the next addition.
We will use the ^ZZLIB3 global in Lesson 4 to produce a web page table of the names sorted by all three methods.
Tutorial Home: M Web Tutorials Prev: Lesson 3 Next: Lesson 5