Tips And Tricks


Fastest "1 TO x" loop when x is not a constant

It's ~30% faster to use "DO i = x TO 1 BY -1" than the closest "DO i = 1 TO x", even when x is calculated before the loop,


COMPILE with optimal PROPATH

Make sure that the PROPATH in use at the time you use the COMPILE statement have the source code folders available as the first folders. That's also true for the PROPATH used by OE Architect's syntax analysis.


DO loop instead of REPEAT

The DO loop constructs are much faster than the REPEAT loop (when you don't need the extra that REPEAT provides... if you don't know what the extra is, you probably don't need it).


Fastest way to aggregate a character list

The fastest way to aggregate a list of character values when all values are non null is to *always* add the delimiter *before* the next element inside the loop and remove it afterward with cList = SUBSTRING(cList, LENGTH(cDelimiter) + 1)


SEARCH for file existence

The SEARCH function is 30 to 70% faster than FILE-INFO:FILE-NAME to test for file existence if you expect that the file searched exists most of the time (if the file does not exist, both methods are equivalent).


Fastest way to test that a character value contains nothing

When you want to verify that a character value does not contain any character (i.e. it is "" or ?), using the construct TRUE <> (someCharacterExpression > "") is your best buy


FORWARD-ONLY on QUERY

Use FORWARD-ONLY = TRUE on a QUERY that just goes from a record to the next (as a "FOR EACH" does).


For temp-tables, let ABL fail on unique index instead of using a CAN-FIND prior to creating each record

When adding records to a temp-table having at least a unique index, it can be faster to trap the ABL error generated on a collision instead of using a CAN-FIND prior to creating each record.


ASSIGN for speed when assigning variables or fields.

Assigning values to any number of variables is always faster when grouped in an ASSIGN statement compared to being set independently.


Fastest way to test that a character value contains something

When you want to verify that a character value contains characters, using the construct:
someCharacterValue > ""
is, on average in my test, 10% (for a void string) to 27% (for a ? string) faster than the second fastest construct (not to mention that it is also shorter to type; not to mention that it is also 33% to 50% faster then the slowest of the constructs presented here)


Syndicate content