Re: Total beginner's question
- From: "NickName" <dadada@xxxxxxxx>
- Date: 17 Aug 2006 12:29:19 -0700
Interesting, Cache seems to be the "Unifier"?
Mike Minor wrote:
I work in a variety of flavors of M environments: DTM, DSM, ISM, Cache....I
use the Cache Explorer to import the routines, and the I use the Cache
studio to work on all of my routines. Whe done I then use Cache Explorer to
export them in the proper format for loading onto the various systems.
The Cache studio has a feature that will expand the abbreviated commands to
the verbose commands, and to change verbose commands back to abbreviated
commands: control-E to expand and control-shift-E to compress the commands.
Hope that helps....
Mike MInor
Z-Code Systems, Inc,
"Pete" <peter.charbonnier@xxxxxxxxx> wrote in message
news:1155753023.196583.77600@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Abbreviation is probably going to be an issue with most of the "old" M
code that you try to read, and is a real pet peeve of mine when it
comes to MUMPS.
<rant>
Would it be impossible for M to have a "verbose" toggle so that
commands could be expanded into more legible english? Memory isn't as
rare as it used to be, and something like that would really be handy in
debugging and in not scaring away new users.
</rant>
Anyway, here are the big ones that I can think of:
W = Write
R = Read
I = If
S = Set
G = Goto
Q = Quit
K = Kill
D = Do
N = New
F = For
That's about 99% of what you'll encounter. It can make reading M
difficult when compared to something like VB, but then VB isn't nearly
as cool.
NickName wrote:
Please see my comments/further questions below, thanks.
lmv wrote:
See comments in-line.The W above is a short form of WRITE? And for that matter, can any
NickName wrote:
Aaron Seidman wrote:
Here's a simple (if hokey) M routine as an example:RTNNAME for Return Name? Forgive me I would spell it out as
RTNNAME ; This is the first label, which is also the name of the
routine
; You may want to add additional comments to explain the action or
; for simple readability
RETURNNAME
Probably for Routine Name. The older MUMPS applications had a
limitation on the length of things like routine names, variables,
labels, global names, etc. The limitation was that they had to be 8
characters or less. Some of the newer MUMPS apps allow for more now,
but some programmers still don't go over 8.
Also, a lot of the very first routines that were written had a big
limitation - routine size. Routines had to be very small and so a lot
of the early programmers used single letter variables and scrunched as
many commands as they could onto 1 line to save on line feeds. The
programs work fine, but they are a bit difficult to read.
; ----------------------------------------------------------------I=1:1:4
START ; Second label
FOR I=1:1:4 DO LOOP,FILE ; execute subroutines four times
meaning
Index/indexing, initiatialization it at 1, start at 1, end at 4,
hence
loop four times.
If the above interpretation is correct
then why would we need "initiatialization it at 1, start at 1" both
since one of them would do?
Someone else replied to this, so I thought I'd spell out some
variations of the FOR loop.
FOR I=1:1:4 DO LOOP ;--already seen this
FOR I=0:100:10000 WRITE !,I ;start at zero, increment by 100, end at
10000 and write the variable I out
SET STOP=0 FOR DO LOOP QUIT:STOP ;an infinite loop that only stops
if the variable STOP is set to 1 (or any non-zero number) - note the
two spaces between the FOR and the DO - this indicates that the FOR
command has no arguments.
FOR I=1,2,6,"A","FRED" W !,I ;loop through a list of specific values
and then write them out
command use a short form and no exceptions?
Could a single quote for 'literal string', e.g. 'FRED', be the same as
double quotes, "FRED" or they must use double quotes. And if double
quotes is required, could single quotes have a place in MUMPS world?
Good to know about what ! means.QUITassign !!,"First name: " to FN (var)
;
LOOP READ !!,"First name: ",FN
READ !,"Last name: ",LN
or
FN is a KEY/field in ^PT?
FN is a variable that holds the answer to the READ statement. Ie. the
user is asked for input and the input is put into FN.
Same with LN.
Reading below seems to suggest the former.
!! and ! in the above two lines respectively, meaning?
The exclamation point used with a READ or WRITE command is a line feed
character. MUMPS was originally developed when there were only dumb
terminals hooked up to servers, therefore everything was written to
display characters to the screen that the user was sitting at.
Nowadays, people use terminal emulaters and such to connect to the
older MUMPS applications and the same logic applies.
So, the <READ !!,"First name: ",FN> command is: Send two line feeds to
the screen, send "First name: " to the screen and then READ user input
(from the terminal) and put the results into FN.
The next line is similar, but there is only 1 line feed.
I don't seem to see the logic of writing data to a user's terminal. DoSET NAME=LN_","_FNWhere does LN_ come from? And for that matter, _FN.
Maybe it's related to the preceding two lines, however, I don't see
syntacal relationship.
Once a variable is defined, it is present until it is killed or your
process is terminated. Similar to global variables in other languages.
This can be both helpful and extremely dangerous. A lot of
programmers will use the NEW command to limit the scope of the
variables that they use. But, basically, if you see a variable in one
label, look to the previous label to see where it got defined.
WRITE:NAME'="" !!,"The name is ",NAMEWRITE command really means to display, yes?
Yes, just like the READ command I wrote about above. This has a
postconditional however, so the statement reads as follows: WRITE (to
the screen), if NAME is not equal to the empty string, two line feeds
and the string "The name is " and the contents of the variable NAME.
;
; The next line assumes the existence of a global node called
; ^PT("INDEX") with some integer value.
;
SET KEY=^PT("INDEX")
SET ^PT("INDEX")=KEY+1
QUIT
;
FILE SET ^PT(KEY,"NAME")=NAME ; saves value of NAME in a global
node
SET ^PT(KEY,"NAME")="" ; resets global node value to the empty
; string (i.e. blank value)
KILL ^PT(KEY,"NAME") ; removes global node from database
QUIT
OK, here's what your above code seems to have achieved.
1) Displays four names (ln, fn) sequentially according INDEX position
of each;
Well, not quite. Since this was silly code, he asked the user for a
name, and then displayed what they entered and then saved it to a
global and then killed it right away. Not useful.
2) Write the these datasets to a file, what's file name? Not
indicative from the code.
The default device used is the screen or terminal emulater that the
user is presummably sitting at. If the Input/Output was being read
in/written out to something else, the USE command would be present.
Essentially, USE indicates an alternate device.
MUMPS programmers usually export these files at users' terminals back
to a centralized database or something similar?
3) The ^PT node (global variable) was removed permenently from the
database.
Correct.
Is the portion of code starting from FILE as a LABEL executed 4 times
as well?
If so, the statement of "KILL ^PT(KEY,"NAME") ; removes global node
from database"
can be, better, should be outside this LABEL, best, below the LABEL.
Correct.
.
- References:
- Total beginner's question
- From: NickName
- Re: Total beginner's question
- From: Denver
- Re: Total beginner's question
- From: NickName
- Re: Total beginner's question
- From: Aaron Seidman
- Re: Total beginner's question
- From: NickName
- Re: Total beginner's question
- From: lmv
- Re: Total beginner's question
- From: NickName
- Re: Total beginner's question
- From: Pete
- Re: Total beginner's question
- From: Mike Minor
- Total beginner's question
- Prev by Date: Re: Total beginner's question
- Next by Date: Re: Total beginner's question
- Previous by thread: Re: Total beginner's question
- Next by thread: Re: Total beginner's question
- Index(es):
Relevant Pages
|
Loading