Guaranteed exit code with ON-EXIT

Here’s handy: The ON-EXIT operation code begins the ON-EXIT section. The ON-EXIT section contains code that runs every time that the procedure ends, whether it ends normally or abnormally. The ON-EXIT section runs under the following conditions: The procedure reaches the end of the main part of the procedure. The Read more…

Converting to CHAR with leading zeros

This is as much a reminder to myself as anything else because the %CHAR built in function has the unfortunate behaviour of stripping leading zeroes when converting a number to a character value. Sometimes I need to keep those leading zeroes, for example when handling elderly date fields. Fortunately, there’s Read more…

Using %TLOOKUP: An example

Firstly, a disclaimer. The CTDATA definition keyword indicates that an array or table should be loaded at compile time. This is a terrible idea for a whole host of reasons, not least of which is that the data is locked away in the program and that you need a programmer Read more…

Fun with varying length fields

So here’s a really simple little program that puts the first five characters of a ten character field into a five character field. So why doesn’t it work? **Free // Fun with variable length fields ctl-opt dftactgrp(*no) actgrp(*new) main(Main); dcl-proc Main; dcl-pi *n end-pi; dcl-s LongString varchar(10) inz(‘123’); dcl-s ShortString Read more…