Difference between revisions of "Hello world and hello Texas from Database"

From VistApedia
Jump to: navigation, search
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Install VistA with something like Astronaut. Get to a Mumps prompt: choose item 3 if you are using VistA Commander.
+
Install VistA with something like Astronaut.  
 +
Get to a Mumps [[Prompt~|prompt:]] choose item 3 if you are using VistA Commander.
 
   
 
   
MUMPS>write "hello world"
+
MUMPS>write "hello world"
 
  hello world
 
  hello world
MUMPS>write "hello " write $P(^DIC(5,48,0),"^",1)
+
MUMPS>write "hello " write $P(^DIC(5,48,0),"^",1)
 +
hello TEXAS
 +
MUMPS>write "hello ",$$GET1^DIQ(5,48,0.01,,,"ZERROR")
 
  hello TEXAS
 
  hello TEXAS
  
What the above hello TEXAS line does:
+
What the first hello TEXAS line does:
  
* Invokes the $P[iece] command, which is similar to but not exactly like the substring command in many other languages.
+
* Invokes the [[MUMPS Functions $PIECE|Mumps function $P[iece]]], which is similar to but not exactly like the substring command in many other languages.
* The ^ indicates that this is not a local variable; MUMPS will look for a [[Global~|global]] stored on disk and visible to other users.
+
* The ^ indicates that this is not a local variable; Mumps will look for a [[Global~|global]] stored on disk and visible to other users.
* DIC's subscripts say to look in the data DICtionary in file 5, field 48, item 0.
+
* The global DIC holds the [[File Of Files~|File of Files]], but ^DIC with the subscript 5 says to look in file 5 (The STATE File)
 +
* The ^DIC(5, is followed by a 48, which means entry 48 in the STATE File.
 +
* The ^DIC(5,48, is followed by 0 because the NAME Field is stored in node 0 and the first piece.
 
* Then $P uses the ^ in this case as a delimiter, and returns the first piece.
 
* Then $P uses the ^ in this case as a delimiter, and returns the first piece.
 
* Since ^DIC(5,48,0)="TEXAS^TX^48^^1^1", MUMPS writes "TEXAS".
 
* Since ^DIC(5,48,0)="TEXAS^TX^48^^1^1", MUMPS writes "TEXAS".
 +
 +
What the second hello TEXAS line does:
 +
 +
* invokes a FileMan function named $$GET1^DIQ  which does the same thing as the first hello TEXAS line.
 +
& the first argument is the number of the file as the source of data.

Latest revision as of 23:06, 21 November 2016

Install VistA with something like Astronaut. Get to a Mumps prompt: choose item 3 if you are using VistA Commander.

MUMPS>write "hello world"
hello world
MUMPS>write "hello " write $P(^DIC(5,48,0),"^",1)
hello TEXAS
MUMPS>write "hello ",$$GET1^DIQ(5,48,0.01,,,"ZERROR")
hello TEXAS

What the first hello TEXAS line does:

  • Invokes the Mumps function $P[iece], which is similar to but not exactly like the substring command in many other languages.
  • The ^ indicates that this is not a local variable; Mumps will look for a global stored on disk and visible to other users.
  • The global DIC holds the File of Files, but ^DIC with the subscript 5 says to look in file 5 (The STATE File)
  • The ^DIC(5, is followed by a 48, which means entry 48 in the STATE File.
  • The ^DIC(5,48, is followed by 0 because the NAME Field is stored in node 0 and the first piece.
  • Then $P uses the ^ in this case as a delimiter, and returns the first piece.
  • Since ^DIC(5,48,0)="TEXAS^TX^48^^1^1", MUMPS writes "TEXAS".

What the second hello TEXAS line does:

  • invokes a FileMan function named $$GET1^DIQ which does the same thing as the first hello TEXAS line.

& the first argument is the number of the file as the source of data.