Release 10.1A: OpenEdge Development:
AppBuilder

> ## Access section (adeuib/_accsect.p)

> Use the `adeuib/_accsect.p` procedure to read and write code sections in AppBuilder:

> Calling sequence
>     RUN adeuib/_accsect.p
>       ( INPUT        pc_mode ,
>         INPUT        pi_context ,
>         INPUT        pc_section ,
>         INPUT-OUTPUT pi_srecid ,
>         INPUT-OUTPUT pc_code
>       ) .

> ##### Input parameters

> The `adeuib/_accsect.p` procedure takes the following input parameters:

> ``pc_mode``

> A quoted character string that specifies the mode of operation. Valid values are:

> - `“GET”` — Reads the contents of the section or returns unknown (`?`).
> - `“SET”` — Writes the contents of the section.
> - `“DELETE”` — Deletes the current section.

> You cannot actually delete either the `MAIN-CODE-BLOCK` or the `DEFINITIONS` sections (see `pc_section` below). The `DELETE` value empties the section but does not also remove the stub.

> ``pi_context``

> The context ID of the object to access. If unknown (`?`), AppBuilder assumes the current window or procedure.

> ``pc_section``

> The name of the code section to access. Valid values are:

> - `DEFINITIONS`
> - `MAIN-CODE-BLOCK`
> - `TRIGGER:``event-name`
>   (For example, `TRIGGER:CHOOSE`)
> - `PROCEDURE:``name`:`handler
>   `(For example, `PROCEDURE:mytest:maintain.p`. See the “Examples” section below for a description of how you can use this.)
> - `FUNCTION:``name`
> - `XFTR:``xftr-name`

> When you have a `TRIGGER`, then `pi_context` refers to a widget. In all other cases, `pi_context` points to the procedure.

> If `pi_srecid` is unknown (`?`), then `pi_context` and `pc_section` are used to identify an existing section. If `pi_srecid` is known, then `pc_section` is ignored.

> ##### Input-output parameters

> The `adeuib/_accsect.p` procedure uses the following `INPUT-OUTPUT` parameters:

> ``pi_srecid``

> The context ID of the current section. If its value is other than unknown, `pc_section` is ignored.

> ``pc_code``

> The contents of the trigger or other code section.

> ##### Return values

> This procedure returns:

> `“Error”`

> Indicates that `pi_context` is not specified and there is no current procedure or window.

> ##### Examples

> The following code resets the `MAIN-CODE-BLOCK` to an include file:

>      /* Get the current value */
>       pi_srecid=?.
>       RUN adeuib/_accsect.p ("GET", ?, "MAIN-CODE-BLOCK",
>                              INPUT-OUTPUT srecid
>                              INPUT-OUTPUT code).
>       IF RETURN-VALUE NE "Error" THEN DO:
>         IF code ne "{include.i}" THEN DO:
>            code = "{include.i}".
>            RUN adeuib/_accsect.p ("SET", ?, ?,
>                                   INPUT-OUTPUT srecid,
>                                   INPUT-OUTPUT code).
>         END.
>       END.

> The following example creates a AppBuilder-maintained procedure: a procedure that the Code Section Editor displays as a `READ-ONLY` procedure. The following code fragment calls `adeuib/_accsect.p`:

>     DEF VAR section_id as INTEGER INITIAL ?.
>     DEF VAR code AS CHAR .

>     RUN adeuib/_accsect.p(INPUT "SET":U,
>                           INPUT ?,
>                         INPUT "PROCEDURE:mytest:maintain.p",
>                          INPUT-OUTPUT section_id,
>                          INPUT-OUTPUT code).

> In this example:

> - The first `INPUT` parameter, `“SET”:U`, specifies `SET` mode; `SET` mode tells `adeuib/_accsect.p` to write or create a code section.

> - The second `INPUT` parameter, `?`, specifies the context ID of the object to access. By default, `adeuib/_accsect.p` interprets the unknown value (`?`) to be the context ID of the current window or procedure.

> - The third `INPUT` parameter, `“PROCEDURE:mytest:maintain.p”`, specifies the following:

> - The type of section to create is an internal procedure.
> - The name of the internal procedure is mytest.
> - The procedure `maintain.p` handles generating the code for the internal procedure.
> - The first INPUT-OUTPUT parameter specifies the context ID of the section; this value must be unknown (`?`) or `pc_section` is ignored.

> - The final INPUT-OUTPUT is a character string that holds the contents of the section.

> This `maintain.p` procedure generates the code for the mytest internal procedure:

>     /*----------------------------------------------------------------------
>     File: maintain.p

>     Description:
>         Sample procedure showing how a developer procedure can maintain
>         a AppBuilder Code Section.
>     Input Parameters:
>         p_id  - (INTEGER) context ID of the current procedure

>     Output Parameters:
>         p_Code - (CHAR) code to return. (Including "END PROCEDURE." ).

>     ------------------------------------------------------------------------*/
>     DEFINE INPUT  PARAMETER     p_id      AS INTEGER    NO-UNDO.
>     DEFINE OUTPUT PARAMETER     p_code    AS CHAR       NO-UNDO.

>     DEFINE VAR ch AS CHAR NO-UNDO.

>     /* Line for comments. */
>     &Scoped-define COMMENT-LINE
>     -----------------------------------------------------------------------
>     /* Standard End-of-line character */
>     &Scoped-define EOL CHR(10)

>     /* Get some info about the current procedure. */
>     RUN adeuib/_uibinfo.p (p_id, ?, "FILE-NAME", OUTPUT ch).

>     p_code =
>     "/*{&COMMENT-LINE}" + {&EOL} +
>     "  Purpose:     Sample code for file " + ch + {&EOL} +
>     "  Parameters:  <none>" + {&EOL} +
>     "{&COMMENT-LINE}*/" + {&EOL} + {&EOL} +
>     "   MESSAGE ’Hello World!’:U." + {&EOL} + {&EOL} +
>     "END PROCEDURE.".

> The `maintain.p` procedure generates a mytest procedure that the Code Section Editor displays as read only. Here are the contents of the generated mytest procedure:

>     /*-----------------------------------------------------------------------
>       Purpose:     Sample code for file C:\WORK\V-CUST.W
>       Parameters:  <none>
>     ------------------------------------------------------------------------*/

>        MESSAGE ’Hello World!’:U.

>     END PROCEDURE.

> AppBuilder-maintained procedures provide an alternative to traditional `XFTR` use. They basically fill the role of an `XFTR` with only a single `WRITE` handler. The advantages of AppBuilder-maintained procedures overusing `XFTR` are:

> - You can add and delete them programmatically using `adeuib/_accsect.p`.

> - They are visible to you, the developer, so that you can see the code being generated.

> Their disadvantages are:

> - They can be deleted by the user from the Code Section Editor menu (Edit/Delete Procedure).

> - They cannot store data in comments used to rebuild the code section. That is, the contents of the AppBuilder-maintained procedure must be derived totally from external sources or calls to `adeuib/_uibinfo.p`. For example, an `XFTR` handler can read a section and have it affect what it generates; however, an AppBuilder-maintained procedure can only write code.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095