Inside VESOFT #09 (looping constructs)
Shawn Gordon

First the big news. There is a new version of MPEX available for MPE/iX 6.5 that is supposed to handle the large files that are now available. I don’t have 6.5, the new MPEX or enough disc space to test it, so I can’t really tell you anything except I don’t recommend an ALTFILE of a 20 gigabyte KSAM file.

I’m going to talk about the various looping constructs in the VESOFT product line and how you can make use of them. First there is the %WHILE…%ENDWHILE which operates pretty much the same as the one in the CI. It can be used in MPEX and STREAMX most usefully and in any situation where you need a general purpose loop. Here is a simple example:


Next there is the %REPEAT…%FOREACH loop. This reminds me of the “for I =1 to I” type loop in BASIC. However, as most things in MPEX go, it can be streatched much further, for example:

%>ECHO Creating group and user for !NAME

My all time favorite and most used tool is the %REPEAT…%FORFILES loop. This is where you can create command files that operate on file sets for special purpose issues. As you work more and more with MPEX, you will find yourself turning to this construct. Here is a simple example:

%>ECHO —–Processing file !MPEXCURRENTFILE

Next we have %REPEAT…%FORJOBS, which is very handy for working against job sets for a particular action that isn’t directly support by the ALTJOB/BREAKJOB/ABORTJOB/RESUMEJOB commands. As an example

%>ECHO -----Processing job ![RJOB.FMTJOB] ![RJOB.FMTLOGON]

You have a flexible method for altering batch jobs or aborting them depending on their value.

The %REPEAT…%FORNUM I don’t find as much use for, but it is handy for doing things sequentially and is much more similar to the “for I = 1 to I” construct I explained earlier:

%>FORNUM I=1,9

Now %REPEAT…%FORRECS is one of those that I haven’t gotten around to using yet because I always forget about it. It a nice sneaky way to read a file and do stuff, example:


The %REPEAT…%FORRECS construct performs a sequence of MPEX commands once for
each record of a given file, with a given variable (for example, “CURRENTREC”) set to each record of the file:


will do the commands between “%REPEAT” and “%FORRECS” once for each record in the file DATAFILE, setting the variable CURRENTREC to the contents of the current record.

We now get to the only Security/3000 specific loop that I am aware of, %REPEAT…%FORPROFILES. This construct allows you to perform an arbitrary set of actions on SECURITY profiles. Although the %SEC CHANGE command lets you change large groups of profiles, and the %SEC LISTUSER lets you report on any set of profiles, there are still some limitations to these commands. The %SEC CHANGE command is limited to changing ALL the profiles in the profileset to have the SAME value, and the %SEC LISTUSER command displays profiles with only one format.

Using %REPEAT…%FORPROFILES, however, you can change fields of each profile that qualifies with different values (which may even be based upon current values of other fields). Simple reports can be generated by using the %ECHO command to format and display the values of any field within the profile.

For example, lets say you have a user defined field that contains a three-digit department code and you want to change them to be four-digits by adding a “1” to the beginning of each code. The following %REPEAT…%FORPROFILES loop will do just that:

   %FORPROFILES @,@.@(UF('DEPT')<>'')

Now finally we are up to the thre VEAUDIT specific loops, they are:


Basically you have to own both MPEX and VEAUDIT for this to work, and you have to preface the FOR???? With VEAUDIT. Each construct lets you do “things” to MPE accounts, groups and users, for example:

%  COMMENT Copy a file into all groups (except DATA and PUB)
%  COMMENT in the AP account

There you go, all the fun you could possibly hope for in a utility. Until next month……….