Rexx Tool To Check Coding Standards Productivity

05.01.2020

Ever need to code quickly? You can code Rexx like water—yet it’s powerful. Here’s everything you need to start, by studying real-world programming examples. Script for success One magical aspect of the free software movement is the many programming languages available. Among them are the scripting languages, languages designed for highly productive programming or “scripting”. Popular free scripting languages include Perl, Python, Tcl/Tk, Ruby, Bash, Korn, and others. There is quite a variety because each offers its own unique combination of strengths, its own characteristics.

  1. Rexx Tool To Check Coding Standards Productivity Chart

Different languages meet different needs. This article introduces one of the first scripting languages, one that continues to be popular world-wide. Rexx initially rose to prominence as the scripting language for IBM’s mainframe operating systems, the Amiga, OS/2, and other systems. Today nine free Rexx interpreters run on any platform, ranging from phones and handhelds, to laptops and PCs, all the way on up to servers and mainframes.

Rexx Tool To Check Coding Standards Productivity

Of course, this includes operating systems like GNU/Linux, Windows, and Unix. Rexx’s big draw is that it is powerful yet easy to use. Many languages make this claim, but few achieve it. There exists a natural trade-off between power and ease-of-use—the more power designers cram into a language, the more complex that language becomes. Rexx employs specific techniques to pack power while retaining ease of use:. Minimal syntax. Few rules restricting the code (aka free-formatting).

Consistent, reliable behavior. Common-sense defaults (for simplicity) that can easily be overridden (for power). A very small instruction set you can learn immediately, surrounded by larger, powerful function and object libraries you can learn over time.

Language extensibility through add-in function and class libraries. You use these external modules the same way you access built-in language features. Modular and structured. Standardized I’m a big believer in “easy” languages—as long as they still meet my need for power. A language that is easy to code means higher productivity. You can script quickly.

With modular design, I can write tons of small routines and evolve a large application in no time. Easy languages lead to fewer errors. Fewer errors result in more reliable code.

Programs are quick to debug. And they are easier to maintain and upgrade as needs change. This is especially true with large programs. Ever had to maintain someone else’s code written in a syntax-driven language?

Rexx

It can be tough, especially for large or undocumented programs. Many complex languages are very powerful, but programs written with them are hard to enhance and maintain. Scripts written in “easy languages” like Rexx can be modified much more easily. To the degree code grows and changes and needs to be updated, programs written in easier languages have longer lives than those encoded in powerful but complex languages.

Easy languages yield big benefits—even for experienced developers. While some consider it macho to work in powerful, complex languages, the best developers are wildly productive in easier languages. They script as fast as they think. Plus, the companies they work for prefer the maintainability of those languages.

Organizations want living code—code that can adapt and be altered. Complex code doesn’t retain value once its originator “leaves the building”.

Varieties of Rexx There are nine free Rexx interpreters. They fall into two broad categorizes:.

Procedural or “classic” Rexx. Object-oriented The tables below list the Rexx interpreters, the platforms on which they run, and a few of their major benefits.

Regina Nearly all platforms Portable, standard, popular Reginald Windows Excellent Windows integration r4 Windows Includes many useful Windows tools Rexx/imc Linux, Unix, BSD Industrial-strength, nice concise documentation plus tutorial BRexx Most platforms Fastest Rexx, small footprint, lightweight Rexx for Palm OS Palm OS Palm OS integration, text interface. Free Rexx—object-oriented interpreters All the interpreters meet the Rexx standards (except for NetRexx, designed for Java integration). This means that your code is portable across platforms. Stick to the language standards (and limit the operating-system specific commands you issue from within the code), and your code runs anywhere. Your knowledge is transportable too, both across platforms and across the Rexx interpreters. The first two object-oriented Rexx interpreters listed above are true supersets of the classic Rexx standards.

They add complete object-orientation to standard Rexx. This includes objects, classes, messaging, single- and multiple- inheritance, data hiding, polymorphism, class libraries, and all the benefits of object-oriented programming. Since these interpreters meet the Rexx standards, classic Rexx programs run unchanged under object Rexx. This compatiblity both carries older procedural programs into the object-oriented world, and allows you to code whether or not you program using objects. You can mix procedural and object-oriented code however suits you. NetRexx is unique. It is not standard Rexx but a “Rexx-like” language.

Designed for Java integration, it runs on any Java Virtual Machine. It can use Java objects and be used to create objects used by Java programs. It offers an easy way to code for the Java environment. You can download any of the Rexx interpreters from.

The web site also offers hundreds of free add-in tools, and function and object libraries for Rexx, as well as sample code. A sample program Here’s a real-world example of how quick scripting can be useful. The other day I faced a dozen old Windows desktop computers running different versions of Compuserve software. (For those who remember the old dial-up days of a decade ago, Compuserve was a leading vendor for email and early internet access.) My task was to somehow retrieve the contacts in the “address books” stored in the Compuserve software.

I logged on to a few of the old machines and quickly determined that they ran ancient Compuserve software ranging from version 5 all the way back to version 2. These versions of Compuserve all saved their address books in a single file named “ addrbook.dat”. The difficulty is that the information in this file is encoded in a proprietary format. View it with Windows Notepad and you can see the contact information, but it is difficult to read because it’s interspersed with tons of unprintable and miscellaneous characters. Since I didn’t know the Compuserve address book format, I could only guess as to what the unprintable characters represent (length indicators?, flags?, field separators? I found a free program on the web called ForMorph Message Converter that exports old Compuserve information, but I never decoded the file format of addrbook.dat files. If anyone knows, please post it in the comments to this article.) I decided to write a quick Rexx program to dump out the address book information in readable format.

I have used classic (procedural) Rexx in the solution. First, I wrote a quick script just to dump out the file to the screen as printable characters. This meant translating unprintable characters into their hexadecimal (base 16) equivalents.

Then I could see what was actually in the address book files. I could, for example, match the printed hex characters to the character map available in Windows (view it by selecting Start→Programs→Accessories→Character Map). This quickly showed me what the unprintable characters in the file were. The listing below shows what the program output looks like. Each line represents one character from the input file. Each line shows one character along with its hex equivalent to its immediate right. You can see that the letter “p” is “70” in hexadecimal, that the blank “ ” is “20” in hex, and that there are some mysterious characters with the hex value of “00” that do not show up on the screen at all.

Only through this quick dump was I able to distinguish between hex blanks and the hex “00” characters in the file. This particular file was corrupted but I was still able to view its contents. Now I’ve got a better idea of what’s in these address book files. P 70 a 61 g 67 e 65 20 N 4E ® AE A 41. 2E ® AE 00 00 N 4E.etc. Let’s take a look at the code that produced this quick “hex dump”: /./ /.

Mbot 1 2b cracked. Display file contents to the screen as hex characters./ /./ infile = 'addrbook.dat' /. The input file./ do while chars(infile) 0 /. Read the input file,./ inbyte = charin(infile,1) /. character by character./ say inbyte c2x(inbyte) /. Display each character./ end In the code, the first line after the introductory comments sets a variable to the input file name.

The do while loop applies the built-in chars function to the input file. Its effect is to process the file while there are still characters to read. Inside the do while loop, the charin built-in function reads one character from the input file into the variable named inbyte.

The c2x function converts this single character into its hexadecimal equivalent, while the say function displays it on the screen. In this way, the program processes the input file, one character at a time, and displays each on the screen with its hexadecimal equivalent. You can see why Rexx is quick to code in this sample code snippet:. Minimal syntax. Minimal coding rules and no required formatting.

No mandatory program sections. Rexx automatically opens and closes files. Variables do not have to be declared prior to use An important principle is evident here. The behaviors of the last two points make good defaults but can easily be overridden—this is a technique Rexx employs to get simplicity to co-exist with power. For example, need to override Rexx’s default file behaviors and manually open or close a file? No problem, Rexx provides the stream function for this purpose. Use it to specify any kind of file processing you like.

Rexx Tool To Check Coding Standards Productivity Chart

Ditto for variables—you can declare them in advance of use and even issue a command requiring that all variables be initialized before use (useful in large programs where you don’t want to allow uninitialized variables and typos that accidentally become variables). Rexx is ideal for quick scripting yet it allows you to write powerful programs.

This is vital because there’s nothing more disappointing than using an easy programming language only to find yourself running out of power later. An improved program Now let’s expand the example program into something more useful. This version creates an easy-to-read version of the input file and displays it to the user through Windows Notepad. This script is a generic “file viewer”. It converts any binary input file that contains some text into a more readable form, then displays the text to the user. Figure 1 shows how the first part of the program output appears.

Coding

Figure 1: Viewing Program Output Names and email addresses have been altered for privacy reasons, but you can see that the program makes the meaningful information easily readable from the original hard-to-read input file. In order to create a nice, viewable version of the input, the program masks out all the unprintable characters and miscellaneous punctuation.

It converts them all to spaces. The script leaves unchanged only upper- and lower-case letters, the digits 0 through 9, and five meaningful punctuation characters: commas, underscores, colons, periods, and at signs (@). Here is the code: /./ /. This displays the viewable information in an input file./ /./ /. Write printable characters to a file, changing unprintable./ /. characters and low-value punctuation into blanks (spaces)./ /.

Let the user view the file via Windows Notepad editor. String functions in the example program I won’t walk you through the entire example, as its comments are probably sufficient to enable you to follow it. One trick I’d like to mention, though, is the use of the reverse function. The three parts of each address book entry are: name, email address, and optional comments. After each time through the do while loop, the program identifies and extracts the next name and email address from the input string. If the entry includes optional comments, these are left in the input string when the script processes the next address book entry. So, the script uses the reverse function to reverse-order the characters in the comments and name.

Then with the names occuring first in the input string, the script can easily extract this information using the word function (once to retrieve the last name and the second time to retrieve the first name). After the script obtains the first and last names, it uses the reverse function one last time to properly order the characters in the names. To learn more You’ve seen how easy it is to write short scripts to solve small problems, and then to tie them together to solve a larger problem. It would be simple to enhance these scripts to handle special cases in the input data (for example, email addresses that do not start with the string “ INTERNET:” or that do not end in the suffix “.com”). Rexx is ideal for this kind of iterative programming, as are other easy-to-code scripting languages. But is Rexx powerful?

If you still need to be convinced of this, read in Doctor Dobbs Journal showing how Rexx supports all kinds of data structures—based on simple dot notation. In Rexx, dot notation can represent arrays, trees, structures, records, lists, and other data structures. So you create all kinds of data structures in the same, simple manner—like this: datastructure.1 or datastructure.variableA.variableB. Contrast this to syntax-driven languages, where each data structure adds its own unique syntax to the language. Power languages that add syntax for each different data structure typically end up with some pretty complex and unforgiving syntax. Both approaches do the same job. Which is easier?

This is the Rexx philosophy. Power through simplicity. To learn more about Rexx, read this two-part language tutorial. Further describes Rexx and its features and varieties while is an easy language tutorial. All the interpreter download web sites also offer nice language tutorials.

The simple examples in this article are hardly enough to get a feel for the language, much less showcase its features or its power. Download more sample code from the sources. Scroll up on the same page and you’ll see where you can discussed in this article. Hundreds of are downloadable from there as well.

I recommend three key web sites. For Rexx information of all kinds (including downloads), visit. Other excellent web sites include the and the for object-oriented programming.