开发者

Mumps Syntactical conflicts

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

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

But re开发者_Python百科fference doc the syntax i have seen only %%B format but in code they had use like B%%

Bhas


% 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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜