It is currently Thu Mar 28, 2024 1:25 pm


All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Unit 1 - Lesson 5: MUMPS Routines
PostPosted: Sun May 22, 2011 5:55 am 
User avatar

Joined: Wed Nov 17, 2010 8:37 am
Posts: 136
Real Name: Terry L. Wiechmann
Began Programming in MUMPS: 0- 0-1971
Note: This section in the student guide has been edited – you should download the new version.

This lesson covers the standard structure of a MUMPS routine. It describes the top level structure of a MUMPS routine and then substructures.

In MUMPS, a routine consists of one or more lines of code that can be filed as an unit. It is executable and can make returnable calls to other routines. This will become obvious in latter lessons.

Note: You do not have to understand the metalanguage structure to write a line of MUMPS code. However, it is actually quite simple to read once you get used to it. And, it gives you a solid definitional foundation for what you are doing. If you are not interested in all this formality, make sure you do the exercises and then move on to the next lesson. You will find that the best teacher of MUMPS is, in fact, the MUMPS interpreter. If you make a mistake entering a line of code, it will let you know about it. The “>” prompt is a great tool to have available for experimentation.

Unfortunately, MUMPS is somewhat rigid about line structure. Unlike other languages that let you freely intersperse tabs and spaces, MUMPS does not. It's been one of the criticisms of the language. There are ways of generally getting around this restriction such as editors, translators or compilers. However, these are not subjects we want to discuss in an introductory course, so we will just live with it. You will find after using the language for a while it is generally not an issue. However, one syntactical structure tends to be a longer term annoyance (at least for me) – the requirement of 2 or more spaces after an argumentless command when followed by another command or comment.

Since the metalanguage defines the formal structure of the MUMPS language, we should have some idea of what it is saying. As you can see, this lesson uses the metalanguage to define the concept of a routine. If you do not have a computer science background, it may look quit strange. However, the lesson does not give you the basic definitions needed to read the language. I will outline those definitions below.

First, the metalanguage uses the ASCII character set. To get an idea of what that is, refer to the MUMPS Pocket Guide or any of the implementation specific documentation.

Second, we need to define some operators that are used in the language. These operators are used in the definition of a syntactic element.

Operator (Meaning)
::= (definition - read as “is syntactically equivalent to”)
[ ] (optional)
| | (grouping)
... (optional indefinite repetition)
L (list)
V (value)
SP (space)

Additionally, there are some ASCII characters used in the metalanguage that do not have visible representations. To use them, we must give them a visible representation. So:
SP (Space)
CR (Carriage Return)
LF (Line Feed)
FF (Form Feed)

Third, a formal definition of a language element is created by forming a hierarchical definition using “designators”. Designators are simply names that are underlined. They are placeholders for more specific (next level) definitions. The next level may contain designators as well, etc. However, at some point the definitional hierarchy will terminate with primitives.

At this point study the lesson material in the guide. Try to follow the definitional hierarchy.

Here's how to put the definition of a line in real speak:

A line is syntactically equivalent to a levelline or a formalline. A levelline is syntactically equivalent to a label followed by a line start indicator optionally followed by any number of level indicators and ends with a linebody. A label is syntactically equivalent to a name or intlit... etc.

Have patience, you will actually be working with routines in Lesson 7. However, before doing that, we must learn some basic commands. Proceed to Lesson 6 – this is where you actually start writing code. :D

_________________
Terry L. Wiechmann


Top
Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net