Chapter Contents




Displays a menu containing up to 12 choice blocks and returns the number of the user's choice

Category: Window

Values For The Color Argument
See Also


choice=BLOCK(window-name,title,color,text-1, . . . ,
<,icon-1, . . . , icon-12>);

returns either the number (1-12) of the selected block, or one of the following:

if a user requested help for SAS software

-1 to -12
if a user requested help for the block

if a user issued the END, CANCEL, or BYE command

if an unknown command is issued (see WORD).

Type: Numeric

is the title (up to 80 characters) for the window.

Type: Character

is the title (up to 60 characters) for the menu's title box.

Type: Character

is a number from 0 to 33 that represents the combination of colors to be used for the blocks. The colors and numbers are listed in Values for the Color Argument. Some devices do not support changing the background color. If you have specified that icons be used with BLOCK, then the specified color combination may not take effect. The display of icons is host specific, and therefore the color may be controlled by the host operating system. (Under Windows or OS/2, use the Color Palette to alter icon colors. Under X windows, set X resources to control icon colors.)

Type: Numeric

text-1, . . . , text-12
is the text for each block or icon to display (up to 14 characters). The blocks or icons are displayed in groups of four. Blocks for the first four text values are displayed on the first row, blocks for the second four text values are displayed on the middle row, and blocks for the last four text values are displayed on the last row. Twelve values are required, but you can use null values for block positions that you do not want displayed.

Type: Character

icon-1, . . . , icon-12
are numbers for icons to display in place of the blocks. If no values are provided for icons, or if the host system does not support icons, then standard rectangular blocks are displayed. If you specify a number for which no icon is defined, then the default SAS icon is displayed. If at least one icon number is specified, and the total number of icons is less than the total number of text labels, then the default SAS icon is displayed for text labels that lack an associated icon number.

Type: Numeric


The number of text values that you specify determines how many blocks of icons are displayed in the menu. In order to display an icon menu, you must specify at least one icon position, although you can display the default SAS icon by specifying 0 for positions for which a value for text is supplied.

Because BLOCK does not generate a physical display window, window options such as KEYS are not recognized. The BLOCK function windows recognize only DMKEYS settings. To alter DMKEYS settings for a BLOCK menu, you can use GETFKEY and SETFKEY in a program that runs before the BLOCK menu opens. This program must have a display screen associated with it.

This function attempts to display the blocks in the best manner depending upon the characteristics of the user's display device. The function displays up to three rows of four blocks. Blocks are displayed in the order in which the text arguments appear in the function. Only the nonblank choices are displayed, and the blocks in each row are centered in the row.

When the function is called, it queries the current value of choice. If the value of choice corresponds to a valid selection number, the cursor is positioned on the correct block. Otherwise, the cursor is positioned in the upper-left corner of the window.

To make a selection from the block menu, a user must move the cursor to the appropriate block and then press ENTER or click the mouse. BLOCK returns the index of the selection.

If a user presses the HELP key on one of the selections, then the negative of the selection is returned. If a user presses the HELP key while the cursor is not on one of the blocks, then the value -99 is returned.

If a user issues the END or CANCEL command via a function key, then the value 0 is returned.

Use ENDBLOCK to close the menu window that is opened by BLOCK.

Values for the Color Argument lists values that can be used for color.

Values For The Color Argument

Values for the Color Argument
Color Background Border Text Icon Shadow
0 black white white white white
1 black gray cyan gray blue
2 black gray cyan gray blue
3 black cyan cyan gray cyan
4 black gray white cyan gray
5 black cyan yellow cyan blue
6 black gray white blue gray
7 black gray yellow blue gray
8 black gray white red gray
9 black gray white pink gray
10 black gray white yellow gray
11 black gray white red blue
12 blue gray cyan gray black
13 blue gray yellow gray black
14 blue gray white gray black
15 blue gray white magenta black
16 blue gray white red black
17 blue gray white cyan black
18 blue yellow white yellow black
19 blue gray white magenta gray
20 blue gray white red gray
21 gray blue black blue black
22 gray red black red black
23 gray magenta black magenta black
24 gray blue black cyan blue
25 gray cyan black cyan black
26 red gray white gray black
27 red gray black gray black
28 pink gray white gray black
29 pink gray black gray black
30 yellow gray black gray black
31 brown gray gray gray black
32 background* border* foreground* secondary


33 secondary




foreground* background* black
* SASCOLOR window element names.


Create a menu with five choices represented by icons. The first row contains two icons, Outline and Index. The second row contains two icons, Compare Files and Calendar. The third row contains a single icon, End.

Because the CHOICE variable is assigned the value 5 before BLOCK is called, the cursor is positioned on the Compare Files icon when the window opens. When a user makes a selection, the SELECT statement either exits the DO loop or calls another PROGRAM entry. When control returns from the called program, the menu is displayed again.

   do while(choice ne 0);
      choice=block('Writers Toolbox',
        'Main Menu',6,'Outline','Index',
         '','','Compare Files',
         when(1) call display('outl.scl');
         when(2) call display('index.scl');
         when(5) call display('compare.scl');
         when(6) call display('calend.scl');
         when(9) leave LOOP;
         otherwise do;
            if (choice<0) then
            call display('help.scl',choice);
   call endblock();

See Also


Chapter Contents



Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.