skip to main content
OpenEdge Development: AppBuilder
AppBuilder Interface : Editing source code safely: the Section Editor
 
Editing source code safely: the Section Editor
The Section Editor allows you to edit individual code sections of procedure files without risk to later readability by AppBuilder. This is not true of any other editor, including the editor in the procedure window.
Opening the Section Editor
To open the Section Editor, select the object you wish to edit and do one of the following:
*Choose WindowCode Section Editor.
*Click Edit code in the toolbar.
*Type CTRL+S from the keyboard.
You can also double‑click on the object if you have that preference item checked in the OptionsPreferences dialog box. Figure 14 shows the user interface elements visible when editing the Triggers section. The visible elements vary from section to section.
Figure 14: Section Editor physical interface
Choosing a section to edit
There are two ways to choose a particular code section for editing:
*Select a section (Definitions, Triggers, Main Block, Procedures, or Functions) from the Section combo box. The following example shows the section list expanded:
If you select Triggers, Procedures, or Functions as the main category, you must also select an individual Trigger, etc., or click New. Existing Triggers, etc. are listed in the combo box below the Sections list.
*Click List. The List Sections dialog box appears:
This dialog box lists all the sections and subsections that you can edit, to the level of internal procedures and individual triggers. To make a selection, highlight the name and click OK.
Using the Section Editor
The AppBuilder Section Editor is an editing utility that offers modeless text insertion, standard Windows‑style cut‑and‑paste, and is also capable of the following:
*Text search‑and‑replace.
*Transformation of selected text (indent/unindent, comment/uncomment).
*Token insertion by picking from lists.
*Whole‑file insertion.
*Undo of the most recent action, for most actions.
*The ability to delete whole subsections.
Cutting, copying, and pasting text
To cut a block of text, highlight the block of text, then choose EditCut (shortcut: CTRL+X). The Section Editor removes the block of text from the current editing area and places it in the system clipboard.
To copy a block of text, highlight the block of text, then choose EditCopy (shortcut: CTRL+C). The Section Editor copies the block of text and places it in the system clipboard.
Once a block of text has been cut or copied into the system clipboard, you can paste it at any current cursor location by choosing EditPaste (shortcut: CTRL+V).
Finding and replacing text
Within the current editing area, you can search for and replace text strings. To search for a text string, choose SearchFind (shortcut: CTRL+F). The Find dialog box appears:
In the Find What field, type the text string that you want to find. Set search options as needed:
*Activate the Match Case toggle box to make the search case‑sensitive.
*Activate the Down radio button to search forward; activate the Up radio button to search backward.
*Activate the Wrap at Beginning/End toggle box to specify that when reaching the beginning or end of the current editing area, you return to the top or bottom and begin to search again.
When you click OK, the Section Editor searches for the first instance of the text string.
To find the next instance of the text string, choose SearchFind Next (shortcut: F9). To find the previous instance of the text string, choose SearchFind Previous (shortcut: SHIFT‑F9).
To replace instances of the text string with a different string, choose SearchReplace (shortcut: CTRL+R). The Replace dialog box appears:
The following search and replace features are available:
*Find What — Enter the substring to be searched for.
*Replace With — Enter the replacement substring.
*Match Case — Activate this toggle box to match the search target’s case.
*Search All Sections — The default search‑and‑replace is local to the section being edited. To search globally within the current file, check this box.
*Replace All — Click on this button to replace all occurrences of the target substring without further confirmation.
When you use the Replace All option, a message box displays indicating the Replace All is complete and the number of occurrences that were replaced.
Transforming text
A block of selected text can be indented, unindented, commented out, or uncommented by choosing EditFormat Selection, and then choosing the operation desired.
Inserting text from lists
The process of creating code involves entering many reserved words, identifiers, filenames, and similar tokens. The possibilities for error are numerous. To reduce error and, in most cases, save keystrokes, AppBuilder helps you insert text strings for the following token types:
*Database fields
*Event names
*Internal procedure calls
*Preprocessor names
*Queries
*Object names
*Filenames
For each of these items, AppBuilder provides a way for you to choose or specify a text string that AppBuilder inserts into the edit buffer at your cursor location. You can access this capability by right‑clicking in the editing area, or by choosing from the Insert menu.
For detailed instructions, see the “Inserting text-string tokens from lists” section.
Inserting whole files
You can insert (merge) the contents of a whole text file into the edit buffer at the current cursor location. This is convenient if you have used another editor to write some code that you now wish to integrate into your AppBuilder file.
To insert the contents of a text file, choose InsertFile Contents. The Choose Insert File Contents dialog box appears:
Note: Apart from the dialog box title shown by the title bar, and the end result, this is the same dialog box that appears when you choose InsertFilename. Make sure of what you are inserting.
By default, this dialog box points to the src/template directory and lists the header and superprocedure files found there. You can list different files, or files in a different directory, by selecting from the choices in the respective drop‑down lists. You can edit the list of directories by choosing Edit Path, and you can add a directory without editing by selecting a file using the Browse button, which invokes the standard Open File dialog box.
Saving your changes
Since the Section Editor is a feature of AppBuilder rather than a separate utility, it has no Save option of its own. To save your changes, use the FileSave or FileSave As menu items in the AppBuilder main window. This will save all changes made to the current object, not just those you made using the Section Editor.
Undoing your changes
To undo all unsaved changes made to the current editing area, choose EditUndo All. This restores the file to the state it was in when you entered this editing area.
To undo only your most recent unsaved change, choose EditUndo. This option undoes your last edit. If you use Section Editor features such as Insert or Paste, Undo undoes the most recent action. Successive Undos switch between redoing and undoing the previous edit.
Deleting whole sections
To delete all the non‑AppBuilder code in a particular subsection (an individual trigger, procedure, etc.), choose EditDelete Trigger (procedure, etc.) The menu item text varies according to the element you are currently editing.
Caution: You cannot Undo the deletion of a whole subsection, such as a trigger. If you use the EditDelete subsection type function, and then change your mind, you will have to re‑enter all the deleted code. It cannot be recovered by using Undo or Undo All.
Inserting text-string tokens from lists
Database field names
To insert the name of a database field into an editing area, choose InsertDatabase Fields from the Section Editor menu or choose the Section Editor’s pop‑up menu by right‑clicking in the editing area. The Field Selector dialog box appears, as shown in Figure 15.
Figure 15: Field Selector dialog box
This dialog box lets you choose any field for any currently connected database.
To specify a database field:
1. Select a database. The Tables and Fields lists change.
2. Select a table. The Fields list changes again.
3. Select the field names that you want to insert in the current editing area:
*The Select All button selects all of the fields for the current table.
*The Deselect All button deselects all of the currently selected fields.
*To select multiple fields but not all of them, hold down the CTRL key while selecting.
4. Specify a prefix (qualifier) for the field name:
*The None radio button prefixes nothing to the field name.
*The Table radio button prefixes the table name to the field name.
*The Database.Table button prefixes the database and table names to the field name.
5. Click OK to insert the fields. AppBuilder inserts the field names at the cursor location in the current editing area or replaces selected text.
Event names
To insert event names in an editing area, choose InsertEvent Name. The Choose Event dialog box appears, as shown in Figure 16.
Figure 16: Choose Event dialog box
This dialog box displays a list of all events recognized by ABL. To choose a listed event, select it and click OK:
*Use the Event Filters radio buttons to view different types of events.
*To specify a keyboard event, click Keyboard Event.
Procedure/function calls
To insert a call to an internal procedure or function or to a SUPER procedure’s internal procedure or function in an editing area, choose InsertProcedure Call. The Insert Procedure Call dialog box appears, as shown in Figure 17.
Figure 17: Insert Procedure Call dialog box
Table 8 identifies and describes the options available in the Insert Procedure Call dialog box.
 
Table 8: Options on the Insert Procedure Call dialog box 
Option
Description
Procedure Object
Displays the name of the procedure object that is active in the code Section Editor as indicated by the entry THIS-PROCEDURE, any SmartObjects, or super procedures defined for the object. A drop‑down list is available from which you can choose a different procedure object, allowing you to call the procedures and functions for a super procedure.
To edit a Web object, choose web-utilities-hdl from the drop-down list to access the internal entries of the Web utility. The web-utilities-hdl is a procedure handle defined for all Web objects that reference event procedures, method procedures, and API functions of the Web utility object, web-util.p.
Entries in Object
When either the Procedures option or the Functions option is selected, this option displays a list of names of the current procedure object’s procedures or functions, respectively. The procedure call code that you can insert into the code Section Editor from this list displays in the Code to Insert field.
If procedures or functions are for actively running SmartObjects and super procedures, the insert code includes any run‑time parameters for that procedure or function. You might have to replace each parameter name with the appropriate expression (that is, a constant, field name, variable name, or expression) for the specific call in your code. The data type of each parameter displays in comments.
For procedures and functions in the THIS-PROCEDURE object, the dialog box does not provide the run‑time parameters. You can determine the appropriate run‑time parameters by switching to that procedure or function in the Section Editor and reviewing any parameter definitions.
About Entry
Clicking this button displays additional information about the procedure or function currently highlighted.
If the current procedure object is a SmartObject and it has an internal procedure named object‑help, click About Entry to run that procedure in the object, passing the current procedure name as an INPUT parameter. The object can provide procedure‑specific help.
If the object has no object‑help procedure, the Insert Procedure Call dialog box runs AppBuilder online help for the selected procedure.
Code to Insert
Displays the code that you can insert into the code Section Editor’s edit area. You can edit this code before inserting it into the Section Editor.
V8 Call
Clicking this button enables you to access the Insert Procedure Call ‑ Version 8 dialog box to insert Version 8 style ADM RUN, DISPATCH, and NOTIFY procedure calls into code. You might need to use this dialog box if you maintain Version 8 style SmartObjects in the Version 9 AppBuilder.
For more information about the Version 8 functionality associated with the Insert Procedure Call ‑ Version 8 dialog box, see the Progress Version 8 documentation.
The Procedure Object field lists all of the procedure handles (THIS-PROCEDURE or SmartObject instances) referred to in the current procedure file. For a standard window procedure file, THIS-PROCEDURE is the only procedure handle. For a SmartContainer, each SmartObject instance has a handle that is listed, in addition to THIS-PROCEDURE, which is listed for the SmartContainer itself. When you choose a procedure handle in the Procedure Object field, all of the internal procedures or functions listed pertain to the procedure associated with the object.
Note: AppBuilder does not keep track of parameters needed for internal procedures in THIS-PROCEDURE. It does this only for procedures and functions in SmartObject instances used by THIS-PROCEDURE. If you insert a RUN statement for a procedure defined in THIS-PROCEDURE, you must either check to see if the correct parameters are passed or wait for the AVM to do so.
Preprocessor names
To insert preprocessor names in an editing area, choose InsertPreprocessor Name. The Preprocessor names are listed under the Preprocessor tab in the Code References window:
To select a preprocessor name, click on the name and click Insert. For more information about preprocessor names, see the online help.
Queries
You can use AppBuilder’s query‑building dialog boxes to generate a query definition rather than typing in the query. To do this, choose InsertQuery. The Query Builder dialog box appears:
This dialog box is the first in a series of dialog boxes that help you generate a query. For more information about building queries in AppBuilder, see the “Defining and editing queries using Query Builder” section.
When you finish generating the query, click OK. The Section Editor inserts the entire text of the query at the cursor location in the current editing area.
Object names
To insert object names in the current editing area, choose InsertObject Name. The Code References dialog box appears, opened to the Objects tab:
The Objects tab displays the ABL object names of all widgets and SmartObject instances available in the procedure file, as follows:
*The left column contains the name of each widget and SmartObject instance.
*The right column contains the label or title of each widget.
To insert an object, click on it and click Insert. To insert more than one, hold down the CTRL key while selecting. The Section Editor will insert your choice at the cursor.
Filenames
To insert a file’s pathname in the current editing area, choose InsertFile Name. The Choose Insert File Name dialog box appears:
Note: This is the same dialog box that appears when you wish to insert the contents of a file rather than only a filename. Make sure of what you are doing
To insert the file’s pathname, select the filename and click OK. The Section Editor inserts the file’s pathname at the current cursor location in the editing area. By default, this dialog box displays all of the .i and .p files in the src/template directory.