Editing a Stored Procedure

Topics:

Once you have created a procedure, you can open the text editor to view or revise it. The text editor provides sophisticated search and replace functions, code folding, and autocompletion options.

You can open a Master or Access File in the text editor by right-clicking the synonym on the file list and clicking Edit as Text (to edit the Master File) or Edit Access File as Text (to edit the Access File).

Some types of files open in ready-only imode in the text editor, such as when you open a Master File for viewing in Data Assist. In those situations, some text editor options are not available.

Tip: In addition to editing procedure code, you can copy, delete, or move a procedure component using options on the Applications resources tree or file list.

You can edit procedures from the Web Console or the DMC.

  1. From the Web Console sidebar, click Applications, or from the Data Management Console, expand the Server node folder.

    On the Web Console, the Applications page opens.

  2. Expand an application folder.
  3. Right-click a procedure, and select Open.

    The procedure opens in the text editor.

    Tip: Double-clicking the procedure will also open the text editor.

  4. When you have made your changes, click the Save, Save As, or Run icon.

Text Editor Menu Bar Functions

The text editor menu bar is shown in the following image.

The following functions are available.

  • Save. Saves the current text under the same name.
  • Save As. Saves the current text under a new name.
  • Run. Runs the current text, if it is a procedure.
  • Find. Opens the search function.
  • Uppercase. Changes selected text, or the token with the cursor, to uppercase. A token is an unbroken string of alphanumeric characters and underscores.
  • Lowercase. Changes selected text, or the token with the cursor, to lowercase. A token is an unbroken string of alphanumeric characters and underscores.
  • Comment/Uncomment. Toggles comments on and off for the current line or selected lines.
  • Undo. Undoes any number of edits.
  • Redo. Redoes any number of edits.
  • Select All. Selects all of the text in the text editor.
  • Options. Opens the text editor options dialog box.

Text Editor Color Coding

Certain syntax components in FOCEXECs and Master Files are color-coded in the text editor.

  • Strings are displayed in dark green.
  • Comments are displayed in light green.
  • FOCEXEC keywords are displayed in blue.
  • Expression keywords are displayed in gray.
  • Amper variables are displayed in light brown.
  • SQL keywords are displayed in purple.

Searching for Text or a Regular Expression

Clicking Find (magnifying glass) on the menu bar opens the search panel. Clicking the plus sign (+) under the Search for text box opens the Replace section, as shown in the following image.

The following Find options are available.

  • Search for. Enter text in the input field. If you click the Regular Expression button (.*) at the bottom, enter a regular expression. If text is selected when you click Find, the text will automatically be entered in the Search for input field. When there is text in the Search for field, clicking the x next to the term deletes it.

    Note: The bottom row of the Find panel identifies which instance has the focus and the total number of matches found, in the form n of m.

    • Find previous (<)/Find next (>). Enables you to go from instance to instance of matching text.
    • All. Click All to highlight all matching instances and place a cursor on each of them for bulk deletion or replacement.
  • Replace with. Enter replacement text in the input field.
    • Replace. Click Replace to replace the current instance.
    • All. Click All to replace all matching instances.
  • RegExp Search (.*). Click .* to enter a regular expression in the Search for input field.
  • CaseSensitive Search (aA). Click aA to toggle between case sensitive and case insensitive search.
  • Whole Word Search (\b). Click \b to toggle between accepting matches within words and whole words only. A word is an unbroken string of alphanumeric characters and underscores.
  • Search in Selection (S). Searches within the current selection.

The following image shows a regular expression search for the characters colon, left brace, and left bracket, with the focus on instance 2 of 40.

To close the Find function, click x at the right of the Search for row.

Configuring Text Editor Options

Pointing to the down arrow at the right end of the text editor menu bar and clicking Text Editor Options opens the Editor Options dialog box, as shown in the following image.

The following options are available. Click the check box next to an option to toggle the selection on and off.

  • Enable Code Folding. Code folding places down arrows next to certain commands and characters that flow onto multiple lines, so that you can compress them to hide their content. When code is folded, the arrow changes to a right-facing arrow that you can click to unfold the syntax. This option is selected by default.
  • Enable Ctrl-Space Autocompletion. Provides a list of keywords available in the current context when you click the Ctrl key and the space bar together. This option is selected by default.
  • Enable Live Autocompletion. Provides a list of keywords available in the current context whenever you place the cursor in the text editor at a point where a keyword is available. This option is unselected by default.
  • Highlight Active Line. Highlights the line with the cursor in yellow. This option is selected by default.
  • Show Line Numbers. Displays line numbers to the left of each line. This option is selected by default.

When you have finished selecting the options you want, click OK.

Using Code Folding

When code folding is enabled, certain commands and syntax components that flow onto multiple lines can be rolled up so their content is hidden. Lines that can be folded display a down arrow to the left of the line, as shown in the following image.

The following image shows the same content with the DEFINE FILE command folded.

The arrow next to the DEFINE FILE command has changed to a right-facing arrow. Clicking it unfolds the command.

The following commands and characters can be folded.

  • DEFINE FILE.
  • TABLE FILE.
  • GRAPH FILE.
  • MATCH FILE.
  • MODIFY FILE.
  • MAINTAIN FILE.
  • SQL.
  • Parentheses, braces, and brackets that open on one line and close on another line.
  • SEGNAME/SEGMENT in a Master File.
  • END in a Master File (this folds the DBA section of the Master File).

Text Editor Autocompletion

Autocompletion opens a list of supported keywords as you enter text in the Text Editor. Autocompletion is context sensitive. That is, it will only display keywords available in the portion of the syntax that has the focus. If you select a keyword, autocompletion does not parse the syntax to make sure it is correct.

You can enable autocompletion on an as requested basis (Ctrl+Space autocompletion) or whenever a you are entering text where a keyword is available (live autocompletion).

The following image shows an autocompletion list within a GRAPH FILE command.

Click a keyword on the list to insert it into the syntax.

WebFOCUS

Feedback