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


Scanning Speedware with COBOL

By Shawn M. Gordon

In continuing my theme from last month, I’ve decided to share another little gem that makes COBOL useful for Speedware programmers. This was part of our Y2K research at one point in time, and I evolved it into a more generic facility for searching Speedware spec files. Unlike Powerhouse, Speedware keeps an entire system in a single file that gets pseudo-compiled, so you have screens, reports, logic sections, menus, jobs, everything in this single file.

Some people find this daunting, but believe me, it has a lot of advantages. We were able to modify thousands of programs after updating a key field from an I2 to a Z10 in the database, all in an afternoon and then roll the recompiled spec files into production over the weekend. In a conventional shop this would have been overwhelming.

This month’s program is an example of 400-plus lines, shown in Figure 1. The program will allow you to enter up to 10 files to scan and 10 search strings to scan for. The value of 10 is arbitrary, and you can make it whatever you want. (I’m embarrassed to say that the value of 10 is hard coded in the example program and not in a variable, but that makes it a good exercise for you, doesn’t it?)

The idea is a little more sophisticated than just finding a string in a file. We want to know the program name that the string is part of, this means that when we find our string, we have to back up in our reads until we find the program name.

Our example isn’t a long or overly complex program, but it does make use of a number of interesting items that may be unfamiliar to you. We use the FREADDIR intrinsic, so that we can do absolute jumps around in the file to get the information we want; this of course means that we have to FOPEN the file for access.

We are also using a couple of macros, as you will see I still wasn’t out of the habit of using my UPSHIFT macro instead of using the MOVE FUNCTION UPPER-CASE(VAR) TO VAR feature from the ’89 addendum to COBOL. The other macro is just an example of making life easier when you are writing your code.

Take note of the call to FLABELINFO. While this is a rather inelegant and general-purpose abort, the objective to this is to see if the file actually exists. FLABELINFO is a great intrinsic, as you can get a good amount of information, including the first file label, without having to go through the overhead of FOPEN. So checking if the file exists becomes very simple, and if it does, we also get some important pieces of information needed for working with the file, such as the record width and number of records.

This concept has been an example of using Speedware as a target with fixed delimiters for the program names. I could also envision it being used as an XML scanning tool; you could just use the meta data tags as the section delimiters, for example. I’m sure you can come up with some interesting ideas as well.

Shawn Gordon, whose S.M. Gordon & Associates firm supplies HP 3000 utilities, has worked with HP 3000s since 1983.

Copyright The 3000 NewsWire. All rights reserved.