| Front Page | News Headlines | Technical Headlines | Planning Features | Advanced Search |

     

In Pursuit of PRINT tricks

By Steve Hammond

Inside VESOFT covers tips and techniques you can use with VESOFT’s products, especially MPEX.

Last month, I told you how to do a search for text that doesn’t use the PRINT command. As I was preparing that column, I realized there’s a lot to the PRINT command that we’ve never discussed. <ding> Sounds like a good idea for a column!

Check out the MPEX manual and you’ll find almost 20 different parameters you can use in conjunction with PRINT. Some of them you already know — SEARCH is a good example, but that’s just the tip of the old ice cube.

If you need to print files and you don’t want to change the access/modify dates, just %PRINT fileset;KEEPAMDATES

If this is an issue and you always forget the KEEPAMDATES, then you can set the jcw MPEXPRINTKEEPAMDATES=1 either prior to the command or better yet, in the MPEXMGR.PUB.VESOFT file (remember that?).

Let’s say you want the output to go to a specific file rather than the screen; try %PRINT fileset;OUT=filename.

But enough with the simple stuff — let’s get to the fun stuff! Some newer features of PRINT address some interesting issues. Message files (raise your hand if you have ever used a message file) have this habit of the record erasing after you read it. Since PRINT uses the standard intrinsics, using it on a message file would be somewhat counter-productive. So if you are PRINTing a fileset that includes or may include a message file, try %PRINT fileset;COPYACCESS to preserve the message files. (COPYACCESS can be abbreviated to just COPY.)

Ever get screenfuls of output from a PRINT command and spent the next hour trying to filter through all those lines, trying to find specific file names? Again, MPEX has some foresight and comes to your rescue with the HIGHLIGHT parameter. Add that at the end of the PRINT command and the “Printing: filename” will be displayed in inverse video. A bunch easier to find on a multi-screen dump.

What if you only want to look at certain lines in a file? You can declare the starting record number (;START=nn), the ending record (;END=nn) or both in a single command. %PRINT fileset;START=27;END=35 means that only records 27 through 35 (inclusive) will be printed. If you only want to print the last 15 lines of your fileset, then %PRINT fileset;START=-15;NUM.

Threw a little extra into that one! The NUM tacked on the end tells MPEX to display either line numbers or record numbers if they exist — very helpful when dealing with source files. The default is ;UNN — telling MPEX not to put line or record numbers in the output. Sometimes the line numbering can be a little tricky. Often times the last eight characters of a line are considered the line numbering. So if you have a file with numbers in those positions throughout the file, you probably don’t want MPEX considering those as line/record numbers. What to do? What to do?

Use %PRINT filename; NONUMRECOGNIZE.

If you only want certain parts of a line, you’ve got that ability. Actually, this is just part of the string expression manipulation you can do with VESoft products. Never heard of it? Have you read the Appendix to the VESoft manual? There’s almost 40 pages of different expressions you can utilize when you work with MPEX or SECURITY. But where were we? Oh yeah, string expressions:

%PRINT filename; FORMAT=...

The trick is that the FORMAT option does not output the exact record, but instead outputs some function of the record.

FORMAT=R[0:15] — not the square brackets — will only print the first 15 characters of any given line. You can work with TOKEN and REMTOKEN — if you understand those, that’s fine, I don’t have enough space to thoroughly go into it. Check the appendix.

And then there are the “helpers” for the SEARCH. You can do some complex searches, but how good are they if you can’t see them in the proper context? So you have the CONTEXT option:

%PRINT filename;SEARCH=.....;CONTEXT=-5,+5

This says for every line with the string you are seeking, display the five lines before (-5) and the five lines after (+5). That’s the simple option:

%PRINT filename;SEARCH=”IF” or “AND”; CONTEXT=”FUNCTION”, (R[0:5]=”ENDIF”)

Here we’re looking for a line that contains “IF” or “AND” and then we find the line prior to it that contains the string “FUNCTION” and start printing with that line and print until we find a line that has “ENDIF” in the first five positions.

I’ll be the first to admit that I can’t do justice to the power of the PRINT and SEARCH commands here. So RTMALEM — read the manual and learn even more.

Steve Hammond, who works for a professional association in Washington, DC, wishes all of his readers a happy holiday season.


Copyright The 3000 NewsWire. All rights reserved.