Integrating Windows and the FOCEXEC

In this section:

How to:

The windows created with Window Painter are designed for use within an application FOCEXEC. This topic discusses how to integrate the windows into your FOCEXEC.

Syntax: How to Invoke the Window Facility

To invoke the Window facility, insert the following Dialogue Manager command in your FOCEXEC

-WINDOW windowfile windowname [PFKEY|NOPFKEY] [GETHOLD] [BLANK|NOBLANK] 
[CLEAR|NOCLEAR]

where:

windowfile

Identifies the file in which the windows are stored. This is a member name. The member must belong to a PDS allocated to ddname FMU.

windowname

Identifies which window in the file to display first. Can be set in Window Painter or in first window displayed. This is optional.

PFKEY

Enables testing for function key values during window execution.

NOPFKEY

Prevents testing for function key values during window execution.

GETHOLD

Retrieves stored amper variables collected from a Multi-Select window. Does not cause window to be displayed.

BLANK

Clears all previously set amper variable values when the -WINDOW command is encountered. This is the default setting.

NOBLANK

No amper variable values are cleared when the -WINDOW command is encountered.

CLEAR

When FOCUS is being used with the Terminal Operator Environment (described in the Overview and Operating Environments manual), the -WINDOW command clears the screen before displaying the first window. The Terminal Operator Environment screen is redisplayed when control is transferred from the Window facility back to the FOCEXEC. This is the default setting.

NOCLEAR

When FOCUS is being used with the Terminal Operator Environment, the window file's windows are displayed directly over the Terminal Operator Environment screens.

Note: NOBLANK is particularly important in applications that use more than one -WINDOW command.

Transferring Control in Window Applications

When the -WINDOW command is encountered, control in the FOCEXEC is transferred to the Window facility. Control remains with the Window facility until one of the following occurs:

Once control passes back to the FOCEXEC, control only returns to the Window facility if another WINDOW command is encountered.

Example: Window File in an Application FOCEXEC

This example shows an application FOCEXEC and a window file named REPORT which contains three windows: R1, R2, and R3.

The numbers at the left of the example refer to the flow of execution (that is, the order in which the commands and windows are executed).

1. -START 
2. -WINDOW REPORT R1 PFKEY
   -* 
3. -*Control is transferred from the above command
   -*to window R1 in window file REPORT.
   -* 
4. -IF &PFKEY EQ PF05 GOTO LABEL1;
   -*
   -*Control returns to the above command from
   -*window R2 in window file REPORT.
   .
   .
   -LABEL1 
5. -WINDOW REPORT R3
   -* 
6. -*Control is transferred from the above command
   -*to window R3 in window file REPORT.
   -* 
7. -IF &R3 EQ EXIT GOTO EXIT;
   -*
   -*Control returns to the above command from
   -*WINDOW R3 in window file REPORT.
   .
   .
   -EXIT

Note:

  • At Step 3, the user selects an option from Window R1. This option's goto value is R2. Control is transferred to Window R2.
  • The user presses a function key in Window R2. Control is transferred to the FOCEXEC, to the command following the -WINDOW command (Step 4).
  • At Step 6, the user selects the option to exit; no goto value was set for that option. Control is transferred to the FOCEXEC, to the command following the -WINDOW command (Step 7).

The flow of control has certain implications for the design of your window applications:

  • Any time you pass control back to the FOCEXEC, the window or menu option must have no goto value, or else must prompt the user to press a function key (as described in Testing Function Key Values).
  • At some point in the window session, control should return to the FOCEXEC so that the accumulated return values can be substituted for amper variables, and the variables then used in the FOCEXEC.
  • Any time you pass control from the FOCEXEC to the Window facility you must insert the -WINDOW command in the FOCEXEC.
  • Note that it is not necessary to create a new window file for each -WINDOW command; you can simply enter the same file again at any window.
  • To test for a function key value in the middle of a series of windows, remember that pressing the function key automatically returns control to the FOCEXEC; an -IF test command should follow the -WINDOW command, and a second -WINDOW command should be placed after the -IF command to transfer control back to the window file.
  • If you want to clear an existing set of variable values, return control to the FOCEXEC and execute another -WINDOW command with the BLANK option in effect.

To back up a step during window execution, the user may press PF12 or PF24. This does not cause control to pass to the FOCEXEC. However, you can force Dialogue Manager to return control to a FOCEXEC by a PF key setting as described in Testing Function Key Values.

Return Values

When the user responds to your window prompt by entering text, selecting an item from a menu, or pressing a function key, this response is the return value that fills in an amper variable in your FOCEXEC.

There are two ways in which amper variables are most commonly used in FOCEXECs:

The return value collected can be a character string, a number, the name of a file, a procedure name, or part of a FOCUS command.

A return value amper variable in the FOCEXEC has the same name as the window in which it is collected; that is:

 
&windowname

For example, the return value collected by the window MAIN supplies a value for the variable &MAIN.

Example: Return Value in a Menu-Driven Application

Assume that you have written a menu-driven application that enables a user to report from any one of a list of files. You have created a series of windows for this application, one of which is a file names window named FILE designed to collect a return value for &FILE. The window displays a list of all the user's files that meet certain file-identification criteria specified when you created the window.

Your FOCEXEC contains these lines:

-START
-WINDOW EXAMPLE FILE
.
.
.
TABLE FILE &FILE

When the user moves the cursor to SALES and presses ENTER, SALES is collected to be substituted for &FILE in the FOCEXEC:

TABLE FILE SALES

Goto Values

In this section:

When creating your windows, you also assign goto values telling the Window facility which window to display next. These values allow you to move the user through a series of windows, collecting return values for amper variables, without adding lines to your FOCEXEC.

As described in Transferring Control in Window Applications, if you assign no goto value to a menu option or window, control passes back to the FOCEXEC when the user selects that option or presses Enter at that window.

It is important not to confuse these goto values with the Dialogue Manager -GOTO command. The goto value points your application to a new window in the window file; the -GOTO command transfers control to a label in your FOCEXEC.

Returning From a Window to Its Caller

You can return from a window to its caller via the <ESCAPE> option. If you enter this string as the goto value of a window, control returns to the previous window upon completion of the current window, you must enter the right and left carets as part of the goto value.

Window System Variables

In this section:

We have already discussed return values: these are specific to each window. Two other Window facility variables, &WINDOWNAME and &WINDOWVALUE, are specific to the -WINDOW session (not to each window) and receive values when the Window facility passes control from a window file back to the FOCEXEC.

&WINDOWNAME

&WINDOWNAME is an amper variable containing the name of the last window that was displayed before the Window facility transferred control back to the FOCEXEC.

This variable can be used in many ways. For example, if the goto values/function key prompts in a window file allow a user to leave the window file from several different windows, you can test &WINDOWNAME in the FOCEXEC to determine which window the user was in last (and, therefore, which path the user navigated through the window file).

&WINDOWVALUE

&WINDOWVALUE is an amper variable containing the return value from the last window that was displayed before the Window facility transferred control back to the FOCEXEC. If the user selected a line for which no return value was set (for example, a blank line between two menu options in a vertical menu window), then &WINDOWVALUE contains the line number of the line that was selected.

This variable can be used in many ways. For example, if the goto values/function key prompts allow a user to leave the window file from several different windows, and you need to know the return value of the last window the user was in before she or he left the file by pressing a function key, you can test &WINDOWVALUE.

Testing Function Key Values

To test for function key values, you must specify the PFKEY option on the -WINDOW command line. When the PFKEY option is set and a user presses a function key during window execution, the name of that key is stored in the amper variable &PFKEY.

For example, if the user presses PF1, the 4-character value of &PFKEY is PF01. If PF2, the value is PF02, and so forth. If the user presses Enter, the value is ENTR. The value of &PFKEY is reset each time the user presses a function key.

Note that if the PFKEY option is specified, the Window facility's default PF key actions are overridden by the general FOCUS PF key settings. This means that when you specify the PFKEY option, if you still want the standard Window facility PF key actions to be available to window users (for example, PF1 = HELP, PF3 = UNDO), you must use the SET command in your application FOCEXEC, followed by a -RUN command, to explicitly set those actions.

For example, if you specify the PFKEY option but you want to retain all of the Window facility's default PF key actions using the same PF keys, you need to include the following commands before the -WINDOW command in your application FOCEXEC:

SET PF01=HELP
SET PF03=UNDO
SET PF04=TOP
SET PF05=BOTTOM
SET PF06=SORT
SET PF07=BACKWARD
SET PF08=FORWARD
SET PF09=SELECT
SET PF10=LEFT
SET PF11=RIGHT
SET PF12=UNDO
-RUN

When you specify the PFKEY option, any PF key which you want to test for in the application FOCEXEC must be set to RETURN. (HX, CANCEL, and END also function as RETURN within the Window facility, and can be used in place of it.)

For example, if you design your application so that a user can press PF2 to choose an additional menu option, and therefore you want to test &PFKEY for the value PF02 in your application FOCEXEC, then you must include the following SET command before the -WINDOW command in your application FOCEXEC:

SET PF02=RETURN

The SET PF command is discussed in Customizing Your Environment, and in the Maintaining Databases manual.

You can list the current general FOCUS PF key settings by issuing the ? PFKEY command. The ? PFKEY command is discussed in Testing and Debugging With Query Commands.

The variable &PFKEY can be tested just like any other amper variable. Note that the name of the variable is always &PFKEY; it is not linked to a window name like other amper variables collected through windows.

You may test the PFKEY variable repeatedly throughout the FOCEXEC. Additional SET commands are not required.

One of the advantages of using the &PFKEY variable is that it enables you to collect two return values from a single menu. You might, for example, create a window called FILES, which prompts the user to enter the name of a file, then press PF7 to produce a graph or PF8 to produce a report. Both the file name as &FILES and the function key value as &PFKEY would be collected as return values.

It is always important to remember that pressing a function key immediately returns control to the FOCEXEC if that key was set to RETURN (or to HX, CANCEL, or END).

Note: If the cursor is on a menu that has a FOCEXEC associated with it, the FOCEXEC is executed and the GOTO value associated with the menu choice is assumed. The PFKEY is ignored.

In the example above, if the user presses a function key before typing the file name, the &FILES variable is not collected. If the key was set to something other than RETURN, HX, CANCEL, or END, then the action it was set to is invoked, and control remains within the Window facility.

Executing a Window From the FOCUS Prompt

How to:

You can execute a window directly from the FOCUS command prompt.

Syntax: How to Execute a Window From the FOCUS Prompt

EX 'windowfile FMU' [windowname] [PFKEY|NOPFKEY] [BLANK|NOBLANK] 
[CLEAR|NOCLEAR]

where:

windowfile

Is the file containing the windows. It must have ddname FMU, and appear within single quotation marks.

windowname

Identifies the first window to be executed. If a window name is not specified, FOCUS executes the default start window, or the first window created.

PFKEY

Tells FOCUS you will test for function key values during execution.

NOPFKEY

Tells FOCUS you will not test for function key values during execution.

BLANK

Clears previously set amper variables when the window is called. This is the default setting.

NOBLANK

Retains previously set amper variables.

CLEAR

When FOCUS is being used with the Terminal Operator Environment, the screen is cleared when the EX command is encountered. The Terminal Operator Environment screen is restored when the last window in the chain has been executed. This is the default setting.

NOCLEAR

When FOCUS is being used with the Terminal Operator Environment, the screen is not cleared when the EX command is encountered, and any windows are displayed within the Terminal Operator Environment screens.

For example, to execute the window MAIN in the window file REPORT, you could issue EX 'REPORT FMU' MAIN from the FOCUS command prompt, which is equivalent to issuing -WINDOW REPORT MAIN from Dialogue Manager.


Information Builders