Write your first procedure
- Last Updated: October 14, 2024
- 3 minute read
- OpenEdge
- Version 13.0
- Documentation
Your first ABL procedure will be very simple to get you started with the language. Start the Procedure Editor by selecting the second icon from the Desktop.
Before you enter this first procedure, you need to make an adjustment to the code.
There are a fair number of fields in the Customer table, so
the resulting formatting of all the fields in a limited display area would be a mess. In fact,
one of the fields, the Comments field, is so large that the AVM will balk at
displaying it without some guidance from you on how to format and position it.
So it is better to select just a few of the fields from the table to display to make it more manageable. You will select the CustNum field, which is the unique customer number, the Name field, which is the customer name, and the City field, which is part of the customer's address.
In ABL, a list of fields is separated by spaces, so the new procedure becomes:
|
To enter this procedure in the Procedure Editor, type your block of code:
You might notice the following about this code:
- You can type the table name Customer with an uppercase C, or type it in lower-case, or all in uppercase, or however you wish. ABL is entirely case-insensitive when it comes to both language keywords and database table and field names. Uppercasing the keywords is just a convention to aid in code readability, but you could type for each or For Each as well and it would work just the same.
- Typing CustNum in mixed case is just a convention to aid readability.
- The Customer field Name is
the same name as the ABL keyword,
NAME. ABL is relatively forgiving in this way: if the ABL compiler, which processes the code you type in, can distinguish between a word that is a field name or table name and one that must be a keyword, it will let you use it that way. It is a good idea to avoid using keywords as table or field names in your database definition, though. For a list of all ABL keywords, see ABL Reference.
To execute your procedure, press the F2 key on your keyboard (the keyboard shortcut for the RUN command). Alternatively, you can select from the Procedure Editor menu.
The Procedure Editor shows the first set of customer numbers, names, and cities:
To see the next pages of Customer numbers, names and cities, press the SPACE BAR a few times. Press ESCAPE to terminate the display. Otherwise, the display terminates after the last page of Customers has been displayed.
This little three-line procedure certainly does a lot for you, but it doesn't
produce an output display that you would put directly into an application. There are many
qualifiers to the DISPLAY keyword in the statement that you
can use to adjust its behavior and appearance, some of which you will see later in later
topics. Fundamentally, the DISPLAY statement is not intended
to produce polished output by itself for a graphical application. There are other statements
in the language you can use to define the windows, browses, toolbar buttons, and other
features of a complete user interface. You will get to know those statements in later
topics.
For the purposes of your introduction to the language, leave the display format as it is, so that you can see how the structure of the language itself is put together. You will complete a little test procedure here that shows you a lot about ABL. After only a few sections, you will be building complete application windows and all the logic that goes on behind them.