home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / b037_1 / !MUMPS_UserDoc_ProgEnv < prev    next >
Encoding:
Text File  |  1993-06-29  |  10.6 KB  |  291 lines

  1.  
  2. Archimedes MUMPS v1.0 documentation
  3.  
  4.  
  5. PROGRAMMING ENVIRONMENT
  6.  
  7.  
  8. *UCI's*
  9.  
  10. The MUMPS system is divided in so-called UCI's (User Class Identifiers).
  11. Each UCI has it's own set of routines and it's own databases. More than one
  12. user can be 'in' a UCI at the same time, using the same routines and
  13. databases. There is one 'system UCI' in which routines and data are kept
  14. that are global to all UCI's (initially, it is called "SYS"). For instance,
  15. the routine %RD (which displays a routine directory) resides in the system
  16. UCI. In fact, you are not allowed to save routines that start with a '%'
  17. unless you are in the system UCI, the same goes for databases that have
  18. names starting with '%'. However, every UCI has read-access to the system
  19. UCI.
  20.  
  21. So, with UCI's you can have different database systems that do not interfere
  22. with one another, you can keep all routines and data specific to one
  23. database system together, separated from other database systems. 
  24.  
  25. When MUMPS is started you are requested to 'login'. This means that you have
  26. to specify a UCI in which you want to work. For instance, if you wanted to
  27. adapt the %RD routine you would login with "SYS:*", meaning that you want a
  28. programmer's shell in the UCI "SYS" (UCI names always are made up of three
  29. uppercase letters.) It is also possible to specify a routinename after the
  30. ':', in that case the routine will be started immediately, you will not
  31. enter a programmer's shell. For instance, to access your music collection
  32. database as a user (not a programmer, you do not want to edit routines,just
  33. use them!) you type "MUS:MUSIC"; this will run routine MUSIC in UCI MUS,
  34. assuming MUSIC and MUS exist and MUSIC is the routine you want (the main
  35. routine).
  36.  
  37.  
  38. *The programmer's shell*
  39.  
  40. Assuming that you have logged in with a programmer's shell, what can you do
  41. next? MUMPS provides a prompt like this ('_' is supposed to represent the
  42. cursor):
  43.  
  44. >_
  45.  
  46. Since MUMPS is an interactive interpreter you can feed MUMPS commands to
  47. execute, like
  48.  
  49. W !,12*12
  50.  
  51. which will write a new line and then 144, as 12*12 equals 144. Or:
  52.  
  53. F I=1:1:10,"Hello","World",20:1 W " ",I
  54.  
  55. which will produce:
  56.  
  57.  1 2 3 4 5 6 7 8 9 10 Hello World 20 21 22 23 24 25 26 27 28 29 30 31 32 33
  58. 34 35 36 37 38 39 40 41
  59.  
  60. etc. on your screen. The last parameter in the FOR loop (yes, that's what it
  61. was!) specifies an endless loop, it just goes on adding 1 to I and printing
  62. I on the screen. You can interrupt this by typing <Ctrl-C> or <Ctrl-@>.
  63. Typing <Ctrl-C> or <Ctrl-@> always interrupts the foreground process. Ok,
  64. suppose you got fed up with the previous FOR loop after a few minutes and
  65. interrupted the process. What next?
  66.  
  67.  
  68. -Command history-
  69.  
  70. If you now type "?" at the command line something like the following will be displayed:
  71.  
  72.  0: W !,12*12
  73.  1: F I=1:1:10,"Hello","World",20:1 W " ",I
  74.  
  75. Typing "?" at the command line produces the command history. It shows the
  76. last 10 different commands, longer than 3 characters, issued by you at the
  77. command line. It is possible to retrieve a previous command by type "!<n>",
  78. where <n> is the number of the command as displayed in the command history.
  79. So typing "!1" will insert the FOR loop command(s) into the MUMPS
  80. inputbuffer. When a previous command is retrieved, the cursor is positioned
  81. at the end of the displayed text. Pressing <Enter> (or <Return> or whatever)
  82. will execute the command again.
  83.  
  84.  
  85. -Edit keys-
  86.  
  87. When typing commands at the command line there are several 'edit-keys'
  88. available:
  89.  
  90. <Ctrl-U>                : empty the command line
  91. <Ctrl-A>                : move cursor to start of line
  92. <Ctrl-Z>                : move cursor to end of line
  93. <Ctrl-K>                : move cursor one character to the left
  94. <Ctrl-L>                : move cursor one character to the right
  95. <Backspace> or <Del>    : delete character to the left of cursor
  96.  
  97.  
  98. -Routines-
  99.  
  100. What do MUMPS routines look like? Well, just like a normal sequence of
  101. commands you can type at the command prompt, preceded by a 'line start
  102. character', optionally preceded by a label for referencing the line in the
  103. routine. Example:
  104.  
  105. FNAME   R !,"First name? ",NM Q:NM?1.U  W "  Enter your name!" R *R G FNAME
  106.  
  107. "FNAME" is called the 'label' of the line. Just after it there's a <TAB>
  108. character which is called the 'line start character'. After that, normal
  109. MUMPS commands follow. A ';' character when typed where you can type a
  110. command, introduces a comment, for example:
  111.  
  112.         K ^OLDDATA ; delete old data
  113.  
  114. The previous line does not have a label, but it *does* have a line start
  115. character! and a comment, of course.
  116.  
  117.  
  118. -Entering and listing routines-
  119.  
  120. Entering routines is only possible when you are in a programmer's shell. If
  121. the first 'white space' character in the line you typed is a <TAB>
  122. character, the line is inserted in the routine just after the last line
  123. entered, or as the first line if no previous lines were entered. To get a
  124. listing of your routine, just type "P". "P" is short for PRINT, which is a
  125. non-standard MUMPS command that lists the routine currently in memory. The
  126. first line of a program must always be entered in the above described way!
  127. Conventionally, it has the following form:
  128.  
  129. Program name<TAB>;Programmers initials/name;date;Description of routine;
  130.  
  131. For instance:
  132.  
  133. MUSIC   ;HHV; 20 Feb 1992 ;Main routine music database;
  134.  
  135. The ';' after the <TAB> is important, because it introduces a comment! If it
  136. is omitted, "HHV" will be interpreted as a command and generate an error.
  137.  
  138. Usually, it is more convenient to use a routine editor. The supplied editor,
  139. %ED, is an excellent line editor and simplifies editing programs
  140. considerably. You can invoke %ED by typing "X ^%" at the command line. Full
  141. help on the editor is available in the editor itself, just type a "?" after
  142. the ">>"-prompt.
  143.  
  144.  
  145. -Saving routines etc.-
  146.  
  147. If you've entered a routine, save it by typing "ZS" (short for ZSAVE). The
  148. routine will be saved in the current UCI and the name of the routine will
  149. be the same as the label of the first line in the program. If any errors
  150. occur when saving (the routine is checked for syntax errors) you will be
  151. told so and warned that the executable version of your routine is not saved!
  152. This means that you can't run the program yet, but you're 'source code'
  153. will be save (assuming no other serious errors occur), so don't worry!
  154.  
  155. Removing a routine from memory is done with the "ZR" command. To load a
  156. routine from disk use: "ZL <routine name>". Typing "ZL MUSIC" will load the
  157. routine MUSIC in memory, ready for editing again.
  158.  
  159.  
  160. -Obtaining a routine directory and deleting routines-
  161.  
  162. Typing "D ^%RD" at the ">"-prompt will display a routine directory of the
  163. UCI you're in. If you would want to delete a routine from disk, you would
  164. type "ZD <routine name>".
  165.  
  166.  
  167. *Halting MUMPS*
  168.  
  169. ****************************************************************************
  170. *                                                                          *
  171. * IIIII MM M MM PPP   OOO  RRR  TTTTTTT  AAA  N   N TTTTTTT                *
  172. *   I   M M M M P  P O   O R  R    T    A   A NN  N    T                   *
  173. *   I   M  M  M P  P O   O R  R    T    AAAAA N N N    T                   *
  174. *   I   M     M PPP  O   O RRR     T    AAAAA N  NN    T                   *
  175. *   I   M     M P    O   O R R     T    A   A N   N    T                   *
  176. *   I   M     M P    O   O R  R    T    A   A N   N    T                   *
  177. * IIIII M     M P     OOO  R  R    T    A   A N   N    T                   *
  178. ****************************************************************************
  179.  
  180. It is very important that MUMPS is halted in a decent way, namely by
  181. issuing a ZH command (ZHALT) or by logging in with the login name "STOP"!
  182. If MUMPS is shut down by any other means (mains switch/RESET
  183. button/Ctrl-Alt-Delete or whatever) the CHANCE that the database will be
  184. CORRUPT is VERY BIG ! MUMPS uses buffers for data stored on disk in main
  185. memory to reduce access times. These buffers *can* be modified and ZHALT
  186. makes sure that all modified buffers are written to disk. (The MUMPS system
  187. manager updates the modified blocks every second, so only very recent
  188. updates in the database lead to modified buffers in memory. Usually, if you
  189. don't see the disklight for several seconds, there are no modified buffers
  190. in the system. However, this still does *NOT* mean that it is safe to quit
  191. MUMPS in an MUMPS unfriendly way !!!)
  192.  
  193.  
  194. *System utilities supplied with MUMPS*
  195.  
  196. There are several utilities already installed in MUMPS. ***!!! They are
  197. copyright of the programmer !!!***. Whenever a selection of routines or
  198. globals has to made, they may be specified using the wildcard "*", for
  199. instance, "V*" selects all routines whose name starts with a "V".
  200. Routines/globals can be deselected by preceding the specification with a "-"
  201. ("-V*", for instance). Entering "^L" displays a list of already selected
  202. routines/globals. Entering "^D" displays a directory of routines/globals.
  203. The system utilities are:
  204.  
  205.  
  206. %DAT
  207.  - (Dutch) converts the variable %TUM to textual format in the variable
  208. %DAT. For example, if %TUM=55459 then %DAT will be "3 Nov 1992". There are
  209. other entrypoints for %DAT that produce different results:
  210.  
  211. ^%DAT  : 3 Nov 1992
  212. C^%DAT : 03-11-92
  213. D^%DAT : Di, 3 Nov 1992
  214. Z^%DAT : 031192
  215.  
  216.  
  217. %ED & %EDT
  218.  - Routine editor. If you type "D ^%ED" in the system UCI, a global ^% will
  219. be created that contains the routine editor in executable form. Start the
  220. routine editor (in any UCI) with "X ^%". Full help is supplied on-line in the
  221. editor.
  222.  
  223.  
  224. %FL
  225.  - Produces a list of the first lines of all routines in the current UCI
  226.  
  227.  
  228. %G
  229.  - The Global Viewer/Editor. Start %G by typing "D ^%G". Enter a "?" for a
  230. directory of globals defined in the UCI you're in. Enter "??" for help with
  231. the Global Viewer/Editor.
  232.  
  233.  
  234. %GD
  235.  - Gives you a global directory.
  236.  
  237.  
  238. %GDEL
  239.  - Deletes specified globals.
  240.  
  241.  
  242. %GR
  243.  - Restores globals from a file saved by %GS.
  244.  
  245.  
  246. %GS
  247.  - Saves selected globals to a file.
  248.  
  249.  
  250. %GSEL
  251.  - Selects globals and puts selected globalnames in ^UTILITY($I).
  252.  
  253.  
  254. %RD
  255.  - Gives a routine directory.
  256.  
  257.  
  258. %RDEL
  259.  - Deletes specified routines.
  260.  
  261.  
  262. %RR
  263.  - Restores routines from a file saved by %RS.
  264.  
  265.  
  266. %RS
  267.  - Saves selected routines into a file.
  268.  
  269.  
  270. %RSE
  271.  - Finds a string in a selection of routines.
  272.  
  273.  
  274. %RSEL
  275.  - Selects routines and puts selected routinenames in ^UTILITY($I).
  276.  
  277.  
  278. %TUM
  279.  
  280.  - (Dutch) performs the opposite action of %DAT, but has a lot of extra's.
  281. If %DAT is of the form "H"[+/-n], where n is a positive integer and [...]
  282. means that ... is optional, than today is specified with the optional
  283. offset. So, to make things clear, if %DAT="H+1", %TUM will be the internal
  284. MUMPS day-value that corresponds to 'tomorrow'. If you convert %TUM back to
  285. a %DAT value using ^%DAT, %DAT will be "4 Nov 1992", assuming that today is
  286. 3 Nov 1992.
  287. If you leave of the year in %DAT ("1-1") it is assumed you mean this year.
  288. %TUM will convert "1-1" into "1-1-<this year>".
  289.  
  290. /* end of ProgEnv */
  291.