2

I am learning Mumps language while analyzing code got a doubt which is

what is difference between B%% vs %%B.

But refference doc the syntax i have seen only %%B format but in code they had use like B%%

Bhas

bhas
  • 49
  • 2
  • Can you show some line of the code you are analyzing. I think that a double % is not allowed in the current MUMPS implementations. Is %B a local variable or a routine name ? – Sidney Levy Dec 16 '19 at 15:50

3 Answers3

4

% prefix is a convention. It doesn't mean anything to the M(UMPS) interpreter, but does to the programmer. Often % variables are meant to be "scratch" or temporary variables which shouldn't be used for anything more than a line or two of code. e.g.

for %ln=1:1:maxNum do ImportantThing(%ln)  ; loop over lines 1 through maxNum

In normal code you'd declare (new) a variable and use it properly, but this sort of thing is common when introducing "plugin" code, such as an "after booking patient appointment" programming hook for some EHR application.

wilee
  • 601
  • 2
  • 6
  • 19
3

Preceding or ending a variable name with "%%" is allowed. I am not aware of a special significance of using "%'s" in MUMPS variable names, but it is a common 'convention.' Speculating here, but I do note that $,^,& all have special meaning when part of MUMPS variable names and "%" is located near all three in both ascii value and keyboard position.

Perry Horwich
  • 2,798
  • 3
  • 23
  • 51
  • 2
    I beg to differ with you. A local or global variable name in Standard MUMPS may start with a single percent "%" but not more than one. Routines and tags also may start with a single percent "%" character. – David Whitten Oct 18 '12 at 16:29
  • Well, you have had me googling for the last 10 minutes. I cannot find a link to support my assertion, but can say that I worked with a PC based implementation in 1992 that served code that made liberal use of "%%" variables. As I am writing this, I wonder if asking "what is the first character in something like ^%%" might not muddy the waters of this discussion. The original post here seems to be asking about special meaning for %%. I do see it used with mumps variables, but have never read an associated specific import. Have you? – Perry Horwich Oct 18 '12 at 21:47
1

Programs, Globals

In standard MUMPS systems, there is a MGR UCI, where the system and utility programs resides. If a program name begins with "%", it is accessible from other UCIs, too, utility programs' names are beginning with "%", e.g. "%STA" (job status), "%GE" (global edit) and so on. Only programs in MGR UCI could begin with "%".

Also, globals beginning with "%", which resides in MGR UCI, can be accessed from other UCIs.

So, using "%" as the first character of a program or global is the part of the system (or may say, the language).

Locals

MUMPS is a very old stuff, the original language has no local variable support (all the subroutines and main program shares a common namespace). Anyway, user programs can call other programs, utility programs as well: DO FUNCT^%UTILPRG. By convention, utility programs use variable names beginning with "%", so they will no conflict with user program's variables.

So, using "%" as the first character of a local variable, is only a convention, but it is used in utility programs.

ern0
  • 3,074
  • 25
  • 40