Tip use constants to keep code readable

Using the Constants

Let's pretend you have to read code that has been edited by another development partner. You may be skilled and know your "fstat" return values very well. Unfortunately, this is not the case for everyone. The following code is a little bit cryptic to read:
 Read [BPC]BPCNUM=CUST_CODEIf fstat=0Write [ITM]If fstat=3...
Do not forget that your code must be easily understood by other people. If you write the following code, it will be easier to understand:
 Read [BPC]BPCNUM=CUST_CODEIf fstat=[V]CST_AOKWrite [ITM]If fstat=[V]CST_ADUPKEY...

What does fstat=7 mean?

Even if you are skilled in version 6, do you know what fstat=7 means?

With fstat=[V]CST_ARECTICKDEL, you can remember that this status corresponds to the fact that the record with the right updtick is no longer present when a deletion is required.

If you are not an expert, you can also find the list of the most useful constant in the Developer Guide Constants document.

Summarizing the constants management

In several cases of internal functions, the engine returns a numeric status that is not always simple to remember. When dealing with choices input from a local menu (for example a combo box, an enumeration, a set of radio buttons, and so forth), numeric values starting from 1 are returned again, and can confuse the development partner as well as the code reader.

Using supervisor constants with a name starting with [V]CST_A must become a routine. All these constants are defined in the Developer Guide Constants document and their use provides the following benefits:

If you have application parameters that have constant values, do not hesitate creating them. You can create your own constants starting with [V]CST_ followed by any letter other than 'A' it is reserved for the supervisor.
To do this, use the Workbench reference Constants Dictionary document and create your own constants.