|
Toying with
REPEAT...FORNUM Last month, within an hour of finishing the column on REPEAT...FOR commands in MPEX, I encountered a work circumstance where I needed to use the REPEAT...FORNUM command. The circumstance was fairly simple 20 files whose names were FILEnn, where the nn signified consecutive numbers from 1 to 20. I needed to rename the files SERnn. Now, I really didnt want to do 20 renames if I could do the whole thing in one MPEX command. But it actually took a little
playing before I got it right. My first attempt was: But, MPEX supports standard
IF...ELSE...ENDIF processing inside the REPEAT...FOR structure, so I
was able to get it all done in one command: The FORNUM command has more power than just this. The variable actually has three arguments the first is the starting value, the second is the ending value and the final is the increment. So FORNUM zzz=2,10,2 will do five iterations with a value of 2, 4, 6, 8 and 10. It also accepts negative increments. So FORNUM zzz=10,2,-2 will use the value of 10, 8, 6, 4 and 2. I cant honestly think of a reason to do something like that in reverse order, but I am also sure as soon as I make such a statement, I will be deluged with valid circumstances for such commands. Suffice it to say, its out there and you can use it. The next command is
REPEAT...FORJOBS. Just as it sounds, REPEAT...FORJOBS allows you to
perform commands upon sets of jobs/sessions. The attribute and user
definitions are obviously different from those for files, but the
base idea is still the same. Going back to the last example, if
I only wanted the jobs, it would be: The last REPEAT...FOR command is REPEAT...FORPROFILES. This is used in conjunction with Security/3000, the companion to MPEX. You can perform various commands upon a set of Security/3000 profiles inside the REPEAT...FOR. You would generally use the SEC CHANGE or SEC DELETE commands that are part of the overlap between MPEX and Security/3000. To define the profile set, you would use the profile attributes as used in Security/3000. These include anything from account name to the date of the last password change. You use the variable MPEXCURRENTPROFILE to address the selected profile in the command. Id like to add a couple of hints. Dont expect the MPEXNUMSUCCEEDED variable to work inside these REPEAT...FOR loops. My tests have shown that it gets reset to 1 on each iteration. If you need to do some counting, set up your own variable inside the REPEAT...FOR loop and examine it during or after processing. Secondly, and probably more importantly, even though you can do the REPEAT...FOR commands interactively, I advise you not to do so, if just for sanitys sake. Any typos on an earlier line are impossible to correct and can do any number of interesting things. Instead, create a command file using your editor. Then start up MPEX and USE the file. I go one step better since I use Robelles Qedit, which has been hooked to MPEX. (If you dont know about hooking a program to MPEX, do HELP HOOK inside MPEX and select MPEX HOOK for the details.) So I create and keep my use file (lets call it RPTFILE) and then at the Qedit prompt, I type %use RPTFILE to start up MPEX and use the command file. The results are displayed and control passes back to Qedit. Its much easier to test and saves a lot of anguish.
I hope you
have seen how to deal with redundant functions or commands in the
work environment on the HP e3000, and how MPEX makes it easier for us
to be redundant. (Hmmm
that doesnt sound the way I think
it should, does it?) Copyright The 3000 NewsWire. All rights reserved. |