1 / 92

HP3000 Script Programming: Creating MPE/iX UDCs and Command Files

HP3000 Script Programming: Creating MPE/iX UDCs and Command Files. Presented by: Tim Ericson DenKor Dental Management Corp. 1. Audience.

Télécharger la présentation

HP3000 Script Programming: Creating MPE/iX UDCs and Command Files

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.


Presentation Transcript

  1. HP3000 Script Programming:Creating MPE/iX UDCs and Command Files Presented by: Tim Ericson DenKor Dental Management Corp. 1

  2. Audience Any new or experienced HP3000 user, programmer, or systems manager. Familiarity with MPE/iX commands is required, and experience with an editor is needed. Today’s topic will range from the introduction of UDCs and Command Files, to examples of more complex solutions of everyday problems. 2

  3. Research I’ve read a lot of papers on UDCs, JCWs, and Command Files, and I’ve found several fantastic ones! Today’s talk will use some of the examples presented in those papers, and build upon them -- kind of a “The best of the best”. I’ll have some slides later that lists several of these papers. 3

  4. Today’s topics What’s Included Today? What are UDCs; What are Command Files; The calling sequence of UDCs and Command Files; System, Account, and Use-Level UDCs; Recursion; How HPPATH works; Which manual to look in/Where to look on HP’s documentation website (http://www.docs.hp.com/mpeix) for more detail (as we go along); CI Variables and Expressions; Command Interpreter Functions available (especially FINFO); Input and Output Redirection. 4

  5. Free Samples! UDCs and Command Files are frequently distributed on the HP3000-L e-mail list, and some of these will be used as examples throughout the discussion. I have a few that I have created and use on a daily basis, and several others have been sent my way for this tutorial. I have posted them on my web page (http://www.denkor.com/hp3000/command_files) to be freely downloaded. 5

  6. HP3000-L? HP3000-L is a subscription e-mail list. To participate, you must subscribe. After subscription you’ll receive about 50-60 e-mail messages a day, and can submit a question to the group (currently over 700 subscribers). Messages sent to HP3000-L are cross-posted to the COMP.SYS.HP.MPE newsgroup, and messages from there are likewise sent to HP3000-L. 6

  7. What is a UDC? A UDC is a User Defined Command, somewhat like a Unix script or DOS BAT file, and can be a real time-saver. UDCs can be used to create shortcuts by saving keystrokes or executing several command at once. Once a UDC file is created, you must use the SETCATALOG command to catalog the file so the Command Interpreter (CI) can find it (more about the SETCATALOG command later). NOTE! Multiple UDCs (each with multiple commands) can be saved in a single file! 7

  8. What is a Command File? A Command File is very similar to a UDC. Command Files do not have to be cataloged, but must exist in one of the directories in the HPPATH variable (more about HPPATH and variables later, too). NOTE! Only one set of commands be be stored in a Command File! 8

  9. HP’s Definition From the Command Interpreter Access and Variables Programmer’s Guide (found on the HP’s documentation website): “The programming capability of the CI can be used to simplify tasks. Complicated routines requiring multiple commands can be made transparent to users through the use of command files and user-defined commands (UDCs).” 9

  10. Creating A UDC or Command File To create a UDC or Command File, you must use an editor of some sort. The HP3000 has the system EDITOR, but VI (in HPBIN.SYS), HPEDIT (from HP), Qedit (from Robelle Consulting Ltd.), and QUAD (a contributed editor) will all work (and there are probably others). Add or change lines as shown in the examples today, then save the new or changed file. 10

  11. Execution Sequence Another quote from the Command Interpreter Access and Variables Programmer’s Guide: “In processing any command, the CI first checks the UDC files, then the MPE/iX built-in commands. If no match is found, the CI automatically searches for a program file or command file of the same name” (by using the HPPATH variable). WOW! UDCs can override built-in CI commands! NOTE! The “HELP” command works the same way! 11

  12. More About UDC Sequencing When the CI searches the cataloged UDCs, it first looks at User-Level UDCs, then Account-Level UDCs (the ;ACCOUNT option of the SETCATALOG command), then System-Level UDCs (the ;SYSTEM option -- on the next slide). If a UDC calls another UDC, the called UDC must be specified after the calling one (unless OPTION RECURSION is used -- more about OPTIONs soon). 12

  13. The SETCATALOG Command From the MPE/iX Command Reference Manual, on the SETCATALOG command: “Catalogs, or enables, the user-defined commands (UDCs) in a specified catalog file at the user, account, or system level. You can also use this command to disable all UDCs on the system.” (Remember -- this command is not necessary for Command Files). 13

  14. The First Example UDC My first “best of” example is from Dave Largent’s “A Beginner’s Guide to UDCs and JCWs” (an excellent paper for those new to the HP3000 and UDCs), the “J” UDC (we’ll talk about all the sections later): J Header Section OPTION LIST, HELP Options Section SHOWJOB Body Section ** Separator Section 14

  15. More SETCATALOG Info To make the “J” UDC available to the user ACCT.PROD (let’s say the UDC is stored in a file named “JUDCFILE”, and we’re logged on as ACCT.PROD): SETCATALOG JUDCFILE To make the same UDC available to all users in the PROD account (now we’re logged on as MGR.PROD): SETCATALOG JUDCFILE;ACCOUNT 15

  16. SETCATALOG Info, Continued And to make the “J” UDC available system-wide (we’re now logged on as MANAGER.SYS): SETCATALOG JUDCFILE;SYSTEM 16

  17. A similar Command File Here’s that last example, but as a Command File named “J” instead: OPTION LIST, HELP Options Section SHOWJOB Body Section 17

  18. The HPPATH Variable For Command Files, the CI uses the HPPATH variable (remember that UDCs and built-in CI commands are checked first). From the Command Interpreter Access and Variables Programmer’s Guide: “By default, the current group is checked first, followed by the PUB group of the logon account, followed by PUB.SYS and ARPA.SYS.” 18

  19. More HPPATH Info To make the “J” Command File available to the user ACCT.PROD, the Command File must be saved as a file named “J” in the group that the user is currently logged into (let’s say the DATA group) To have the save Command File available to all users of the PROD account, the “J” Command File must be saved in the PUB group of the PROD account. 19

  20. HPPATH Info, Continued Finally, to have the command file available to all users on the system, the file must be saved into PUB.SYS, or into another group (which must exist in the HPPATH variable) that has execute access for anyone on the system. I prefer not to keep any system-wide command files in PUB.SYS, and have created the XEQ.SYS group for this purpose. 20

  21. DenKor’s HPPATH On my machines, the HPPATH variable contains: SETVAR HPPATH “XEQ.SYS,OBJ.COBACCT, !!HPGROUP,PUB,PUB.SYS,ARPA.SYS,HPBIN.SYS” Almost all of the Command Files are saved in XEQ.SYS, which is checked before the COBOL program group, the user’s home group, the user’s PUB group, and PUB.SYS (no command Files are saved in PUB.SYS!) 21

  22. The Header Section In a UDC, the header section is required because that’s where the name comes from! The header section can also be used to pass parameters into the UDC. The header section in a Command File is only needed when passing parameters. To get values into a UDC, you must include variable name(s) in the UDC’s header section, on the same line as the UDC name, or include the PARM statement with the variable name(s) on the next line in that UDC. For Command Files, the PARM statement, if used, is the first line in the Command File.22

  23. Parameters Jack Bailie, in his “MPE/iX Command File Tips and Techniques” paper suggests that each parameter be specified on a separate line, which provides readability, and that we should only use meaningful parameter names (Jack also has several other very good suggestions on style in his paper - see my website). 23

  24. ANYPARM ANYPARM is a special parameter which causes all normal delimiters to be ignored. It must be the last parameter specified, and anything in the command line that appears after the last parameter has been filled is passed in the variable in the ANYPARM statement. 24

  25. Adding Parameters to a UDC Here we see how parameters are passed into a UDC (the “L” command file, from Jack’s paper): PARM fileset=@ ANYPARM format=DISC LISTFILE !fileset, !formatLike this: :L C@, DETAIL;PASS 25

  26. The Options Section There are several options available (as specified in the Command Interpreter Access and Variables Programmer’s Guide):LIST or NOLIST Controls the display of each command image as it is executed. HELP or NOHELP Controls the ability to display the contents of the UDC in help mode. 26

  27. More Options BREAK or NOBREAK Controls the ability to stop execution of a UDC. LOGON or NOLOGON Controls the automatic execution of a UDC at logon. RECURSION or Controls the search for NORECURSION UDCs called from another UDC. PROGRAM or Controls the ability of NOPROGRAM a UDC to be executed27 from a program.

  28. The Body Section The Body Section of a UDC or Command File is where the real work gets done! Here is where the Parameters passed in are worked on, files are checked, and/or programs are run. For instance, we could use the “IF” command with the “FINFO” function to check if a file name passed as a parameter exists or if the file contains any entries. We’ll see more of this section as we continue. 28

  29. The Separator Section The Separator Section is only used in UDCs. Separators are used to tell the CI that the end of the current UDC has been reached, or the end of the current UDC file has been reached. The Separator line must begin with an asterisk (*), must separate each UDC, and must be the very last line in a UDC file. 29

  30. UDC and Command File Differences Also in Dave’s paper is a very complete table of the differences between UDCs and Command Files:Comparison of User Defined Commands (UDCs) and Command Files Execution ConsiderationsUser Defined Commands Command FilesInvoked by typing the Invoked by typing name provided in the the command file's header section of the file name. UDC. 30

  31. Differences, Continued User Defined Commands Command FilesAutomatic execution Automatic execution at logon time is at logon time is available. not available.Executed before MPE Executed after UDCs XL system commands and MPE XL system and command files. commands (unless May override CI. XEQ is used). May commands. not override CI commands. 31

  32. Differences, Continued User Defined Commands Command FilesUser-, account-, and Only "user-level" system-level definitions aredefinitions are available. (Easy available. access at any level could be established with the PATH command.)SHOWCATALOG lists Cannot easily list currently available currently available UDC names. command file names. 32

  33. Differences, Continued User Defined Commands Command Files UDC file is more Command file is secure. (More less secure.difficult to purge (Easier to purge or alter a UDC or alter commandfile.) file.)Best used for Best used for production or stable testing, develop-command definitions. ment, or frequently changing command definitions. 33

  34. Differences, Continued Content Considerations User Defined Commands Command FilesMultiple command Only one command definitions are definition is allowed per file. allowed per file.Header section is Contains no header required. section.May have long, Command name is descriptive command limited to eightname. characters (the34 file name).

  35. Differences, Continued Maintenance Considerations User Defined Commands Command Files Cataloging of the UDC Command files are file(s) is required not cataloged;before use. Available immediately after creation.Must un-catalog the May make changes UDC file before to, or purge themaking changes to, command file or purging the file. directly. 35

  36. Differences, Continued User Defined Commands Command FilesMay provide better Organization may organization of not be as goodcommands (fewer (more files to files). keep track of).System resource use System resource is heaviest at logon use is heaviesttime. at command file execution time.Less disk space is More disk space required. is required.36

  37. Additional Differences One more option -- RECURSION:User Defined Commands Command FilesOPTION RECURSION No OPTION RECURSIONrequired to force the required to have theCI to re-start the CI start searchingcommand search at the at the first UDC.first cataloged UDC. 37

  38. RECURSION Subtleties If OPTION RECURSION is not specified, any UDC that calls another will only look for the called one after the calling one -- the CI will look from the end of the calling UDC to the end of the current UDC file, and then in any UDC file that occurs after the current one in the UDC catalog (like the Account-Level and System-Level UDC files occur after the User-Level UDCs). 38

  39. RECURSION Subtleties, Continued If OPTION RECURSION is specified, any UDC that calls another will cause the CI to start the search for the called one at the very first UDC in the UDC catalog (starting with the first User-Level UDC). NOTE! This feature may be tricky if the UDC being called exists at more than one level! 39

  40. Variables! Variables are used to store values during the current session or job. They are available at the CI prompt, from within UDCs and Command Files, and from within programs (via intrinsic calls). There are a lot of predefined variables, as well! Variables come in three flavors: numeric, string, and boolean. JCWs (job control words) are 16-bit numeric variables, and as such are limited in value from 0 to 65535. 40

  41. Variable Names Variable names can be up to 255 characters long and can include dashes (-) and underscores (_), must begin with an alpha or underscore character, but can include numerics. To prevent variables from being “stepped on” by other UDCs and Command Files, it’s a good idea to follow a naming convention. In a couple of the examples that follow, I’ve used “MY_” as a prefix. HP’s predefined variables all begin with “HP”! 41

  42. Setting Variables There are a few ways to set variables: SETVAR and SETJCW (remember the limitation of JCWs); HPCIPUTVAR and PUTJCW (both intrinsics); INPUT; or as a PARM to a UDC or Command File. You may even change the value of some predefined variables! :SETVAR MY_NUMERIC 123 :SETVAR MY_STRING “ABCXYZ” :SETVAR MY_TRUTH FALSE :SETVAR MY_NEW_STRING MY_STRING + & “!MY_NUMERIC” 42

  43. Displaying Variables Here are some ways to show what’s in a variable: SHOWVAR and SHOWJCW; HPCIGETVAR, FINDJCW, and GETJCW (intrinsics); and ECHO. Wildcards (“@”, “?”, and/or “#”) can be used in the SHOWVAR command. :SHOWVAR MY_@ MY_NUMERIC = 123 MY_STRING = ABCXYZ MY_TRUTH = FALSE MY_NEW_STRING = ABCXYZ123 :ECHO !MY_STRING ABCXYZ43

  44. Deleting Variables The variables defined during any session or job will disappear when you or the job logs off, but... Like using a naming convention for your variables, it’s a good idea to clean up after yourself when you’re done with your variables. DELETEVAR and the HPCIDELETEVAR intrinsic do this for you. :DELETEVAR MY_@ : 44

  45. Using Variables With the exception of five commands (IF, ELSEIF, WHILE, SETVAR, and CALC), you must use an exclamation point (!) before a variable name to get at its contents. In those four commands any non-numeric or unquoted string is an implied variable (implicit dereferencing) Variables are available in all CI commands, as long as you use an exclamation point (!) before the variable name. The CI will substitute the value of the variable in place of its name in the command (Explicit dereferencing).45

  46. Recursive Dereferencing You may include a variable name (with its exclamation point) within the contents of another variable! We’ve already seen this in the HPPATH variable (notice the double exclamation points): :SETVAR HPPATH, “XEQ.SYS,!!HPGROUP,PUB.!!HPACCOUNT,PUB.SYS” 46

  47. Recursive Dereferencing The CI stores the variable-within-a-variable like this: :SHOWVAR HPPATH HPPATH = XEQ.SYS,!HPGROUP,PUB.!HPACCOUNT, PUB.SYSWhenever the ACCT.PROD,DATA user executes a command, the CI interprets this as: “XEQ.SYS,DATA,PUB.PROD,PUB.SYS” 47

  48. Variable Localization Just like the variables that you define during a job or session disappear after you log off, UDC and Command File parameters (from the PARM statement in the Header Section) are local to that UDC or Command File (and are not available to the CI after the UDC or Command File is finished executing). 48

  49. Local Variables Ken Robertson of Robelle Consulting Ltd. in his paper “Programming the Command Interpreter -- An Introduction, a dog, and New Tricks” said it very well:“Local variables cannot be modified, and are accessed only by reference within the command files. If you have a local variable and a permanent variable with the same name, then the local variable takes precedence during expansion.” 49

  50. Local Variables, Continued Ken continues:“Make sure that your local variables have different names from your permanent ones, otherwise you’ll have more confusion than you need at debugging time. The following command file illustrates local versus permanent variable referencing.” parm hpjobname=“ZZTOP” echo Good evening, !hpjobname. Showvar hpjobname 50

More Related