MVS TOOLS AND TRICKS OF THE TRADE March 1996 Sam Golob MVS Systems Programmer sbgolob@cbttape.org Sam Golob is a Senior Systems Programmer working YOUR OWN WORLD OF EDIT MACROS. Today's discussion is like last month's, but with an opposite twist. Last time, we talked about resurrecting ancient MVS editors to help us in times of emergency, when the ISPF editor won't work. Now, we're going to talk about boosting the power of the ISPF editor itself. What is the connection between these apparently opposite topics? True, both topics deal with the process of editing files. But in the first case, we appear to be going back in time. In the second, our "equipment" is very modern and up-to-date. Actually, the true parallel between these topics is inside of you, in how your own mental processes work. In our field (as in life), the name of the game is to grow. In his Foreword to Bill Mosteller's wonderful book, "Systems Programmmer's Problem Solver" (from QED Information Sciences, Wellesley, Mass.), the series editor Gerald Weinberg has likened a systems programmer's job description to that of a goalie in soccer. Most of the time, the goalie is watching the ebb and flow of the game, hoping that the action doesn't come too nearby. On the other hand, the goalie is constantly worrying about contingencies. Can the ball take a tricky bounce into the goal under some strange conditions? We sysprogs are also busy worrying about possible system bugs and loopholes. When we are setting up new systems, as well as while we maintain older ones, we are always trying to anticipate and circumvent possible sources of trouble. The more experience we have, the more educated are our guesses, and the better we are able do this. This process of growth extends to accumulating more tools and techniques. My own systems programming teacher, Jeff Broido, always used to hammer away with the two pieces of advice I mentioned last month: Number one, invest some time every day to learn something new--it will pay you back later in saved time when you're short of time. Number two, always try to find more than one way to do any job. If the usual way won't work, one of the others might work. My experience has shown that these two principles are worth their weight in solid gold. Our current topic, ISPF Edit Macros, provides an opportunity for almost unlimited personal growth in technique. The ISPF edit macro facilities are so extensive that a person's expertise in this area might almost constitute a sub-specialty. Today, I'd like to mention the work of one such expert, my friend Paul Davis, who has chosen to share many of his clever and useful Edit Macros with the public. Some of Paul Davis' work can be found on Files 095 and 251 of the CBT MVS Utilities Tape, an independently produced MVS software collection that can be ordered through the NaSPA office. Before looking at specific examples of Paul's work, I'd like to talk about ISPF Edit Macros in general. A SHORT GUIDE TO EDIT MACROS. The Edit Macro facility was introduced into ISPF rather recently, with ISPF Version 2. Another IBM product, the CMS editor XEDIT which runs under VM, was equipped with a similar facility already. I think that IBM has a tendency once in a while, to pick up the good features of one product, and implement them also in other products, often in the presence of some customer demand. The idea of an Edit Macro is similar to that of a CLIST, which really stands for "Command List". In other words, an Edit Macro is a list of commands. The difference is that a general CLIST is intended to run under native TSO, whereas an Edit Macro is designed to "do its thing" specifically when you are in an ISPF EDIT session. However, Edit Macros are similar to CLISTs in that they are stored together with the CLISTs in the SYSPROC or SYSEXEC library concatenations, nearly always. To complete our picture, we must add that there are also Edit Macros which can be written in programming languages such as Assembler or PL/I. Those Edit Macros are more specifically called "Program Macros", and they are stored in your ISPLLIB concatenation of load modules, or in STEPLIB or in the link list. Before talking about more specifics, I want to mention that a good place to learn about Edit Macros is from the IBM manual: "ISPF/PDF Edit and Edit Macros", which is quite thorough and helpful. You'll find a lot of instruction and specific details there. I would definitely say that this manual will help you learn to write Edit Macros. Paul Davis told me that he uses this manual a lot for reference purposes, but he also has looked for suggestions and examples in other people's files throughout the CBT MVS Tape. If somebody has one bright idea, it is possible that it can be innovatively reused in some new productive way. Our present discussion, for the sake of simplicity, will talk mostly about Edit Macros that are in the form of CLISTs, as opposed to REXX execs or program macros. Most of Paul Davis' Edit Macros are written as CLISTs, and we will want to spend some time describing his work. So let's get started. An Edit Macro is distinguished from an ordinary CLIST by the fact that its first statement is "ISREDIT MACRO". After this initial statement, we often see other ISREDIT statements and ISPEXEC statements in Edit Macros. ISREDIT statements interface with the ISPF Editor to do editing operations, whereas ISPEXEC statements interface with ISPF services in general. Furthermore, all of the CLIST logic services are also available for use. Since an Edit Macro is invoked while we are editing a dataset, its action often works on that same dataset, but not always. ISPF library management services are available, and can be called through "ISPEXEC LMINIT" and similar statements. These services can access any member in the current pds or another dataset, and various actions may be performed on that other dataset. It is actually possible, through the use of Edit Macros, to use an ISPF edit session as a "window" in obtaining some very far-reaching results. However, many of the things we will want to do are ordinary manipulations with the current dataset that is being edited, and their primary purpose is to save us time. For example, suppose you need to convert the entire dataset you're editing, to lowercase. Paul Davis has an Edit Macro (from CBT Tape File 095) called LCASEC to do this in one fell swoop, and the logic is quite straightforward. First he executes ISREDIT CAPS OFF to allow lowercase editing of lines. Then he issues ISREDIT HEX ON VERT to put the edit session into HEX mode. Then he issues a series of ISREDIT CHANGE ALL commands to change (in Hex) all occurrences of each letter to its lowercase equivalent. Now he has to clean up. He issues an ISREDIT HEX OFF to convert the session back to EBCDIC mode, he sets the strings in his "completion messages" and displays them to the edit session, issues an ISREDIT RESET CHG to clear out the "CHG" messages, and positions back to the top of the dataset. This is all quite easy and you can do it too, without very much practice. Something that's harder, is a macro called FIXJCL. The purpose of this macro is to tidy up and align the JCL dataset that you're currently editing. All you have to do is to type the command "FIXJCL" on the command line and press ENTER. The command does the rest. All the complicated editing rearrangements are pre-programmed into the command, and you have almost no work to do yourself. Your JCL member gets neatly rearranged almost instantly, and all that is left, is to eyeball the result to check that no JCL mistakes were introduced by the macro's programming. On the other hand, if you want to learn, you can study this edit macro yourself and understand how the work gets done. Step-by-step, this macro processes your JCL member with various editing techniques, until the ultimate result is produced. A FEW MORE OF PAUL DAVIS' CREATIONS. I recently asked Paul Davis which were some of his own favorite Edit Macros from his collections. I'll mention a few of them now. One handy macro is called BUPMEM (from File 251). BUPMEM is used while editing a SYS1.PARMLIB member. BUPMEM has no parameters, but it instantly makes two backup copies of the member to be changed. If XXXXXXXX is the member that is being edited, then BUPMEM's two copies are called XXXXXXB1 and XXXXXXB2. If XXXXXXB1 already exists, it is renamed to XXXXXXB2 (replacing any old member by that name) and the original member is copied to XXXXXXB1. All ISPF statistics are preserved by BUPMEM. You can see that BUPMEM is a very quick and handy specialized tool for this work. A simple and very useful macro is called FC (Find Line Command) which is on File 095. "FC N" positions you to the next pending edit line command. "FC P" positions you to the previous such command. FC is very nice to have when you can't find where you entered your last unpaired "CC" or "MM" command, if it is a few hundred lines away. The newer WCUT and WPASTE macros from File 251 are an extension of the frequently-used CUT and PASTE edit macros which are now in common use. The difference is that WCUT does not just cut complete lines, to be "pasted" into another dataset. WCUT can cut a small box (rows and columns) of data from one dataset, and WPASTE will paste that box into another dataset somewhere else. This is a true "window cut" and "window paste" facility for ISPF. A sophisticated macro in Paul's collection (File 095) was written to reformat paragraphs in a dataset. It is called PARA. PARA was written by Marvin Greg Berryhill, and it is a very involved and clever piece of work. PARA can take a number of lines of raggedly arranged text, and create a neatly formatted paragraph. Under your direction, the paragraphs can be long and skinny, short and fat, or any shape in between. PARA can even create diamond-shaped paragraphs for unusual effect in a document. All this is done with hardly any work on your part. Without such help, you would be painstakingly arranging each typed line on the page, to create the shape you wanted. PARA also eliminates the need to retype words you have already typed in. I've run out of space for this month, but I hope this will get you to add to your current collection of Edit Macros, and to write some of your own. Edit Macros are wonderful time savers, especially when you have enough of them. Good luck in all of your work. See you next month.