@ ... GET - Option Buttons Command

Included for backward compatibility. Use the OptionGroup Control instead.

This command is undocumented in the original VFP9 help file,
but the following documentation was found in the FoxPro for Windows 2.6 help, and may still be valid:

Creates a set of radio buttons or picture radio buttons.

@ row, column 
GET memvar | field
FUNCTION expC1 | PICTURE expC2
	[FONT expC3 [, expN1]]
	[STYLE expC4]
	[DEFAULT expr]
	[SIZE expN2, expN3
		[, expN4]]
	[ENABLE | DISABLE]
	[MESSAGE expC5]
	[VALID expL1 | expN5]
	[WHEN expL2]
	[COLOR SCHEME expN6 
	| COLOR color pair list]

Parameters

row, column
 Row and column are numeric expressions with values of 0 or greater that determine where the first button in a set of radio buttons appears.

 The first row is number 0 in the main FoxPro window or a user-defined window. Rows are numbered from top to bottom. In FoxPro for Windows, row 0 is the row immediately under the FoxPro system menu bar. In FoxPro for Macintosh, row 0 is the row immediately under the FoxPro title bar. In FoxPro for MS-DOS, row 0 is the row the FoxPro system menu bar occupies. See SET SYSMENU for information about manipulating the system menu bar so you can place output on row 0 in FoxPro for MS-DOS.

 The first column is number 0 in the main FoxPro window or a user-defined window. Columns are numbered from left to right.

 When the first button in a set of radio buttons is directed to a user-defined window, the row and column coordinates are relative to the user-defined window, not the main FoxPro window.

 In FoxPro for Windows and FoxPro for Macintosh, a position in the main FoxPro window or in a user-defined window is determined by the font of the main FoxPro window or the user-defined window. Most fonts can be displayed in a wide variety of sizes, and some are proportionally spaced. A row corresponds to the height of the current font; a column corresponds to the average width of a letter in the current font.

 In FoxPro for Windows and FoxPro for Macintosh, you can position the first button in a set of radio buttons in a window with decimal fractions for row and column coordinates. In FoxPro for MS-DOS, decimal fractions used for row and column coordinates are rounded to the nearest integer value.

GET memvar | field
 When you choose a radio button, your choice is stored to the memory variable or array element memvar or to the field field. memvar or field must be of numeric or character type.

 If memvar or field is of numeric type, a number corresponding to your radio button choice is stored to the memory variable, array element or field specified with memvar or field. For example, if you create three radio buttons and choose the second button, 2 is stored. If memvar or field is of character type, the prompt of the radio button you choose is stored to the memory variable, array element or field specified with memvar or field.

 Initial Radio Button Selection

 When a set of radio buttons appears, the value of memvar or field determines which radio button (if any) is initially selected.

 If memvar or field is numeric, the radio button corresponding to the numeric value is initially selected. For example, if memvar or field is 1, the first radio button you define is initially selected. If memvar or field doesn't correspond to any of the buttons (the value is less than 1 or greater than the number of radio buttons) no button is initially selected.

 If memvar or field is of character type, a case-sensitive comparison is made between memvar or field and each radio button prompt. When the comparison is made, all special characters and any leading or trailing spaces are removed from the button prompts. If a match is found, the matching button is initially selected. If a match can't be found, no button is initially selected.

FUNCTION expC1 | PICTURE expC2
 When creating a set of radio buttons, you must include the FUNCTION clause, the PICTURE clause or both. There is no advantage to any of the three methods. The FUNCTION or PICTURE clause contains the radio button specification code *R and the text for the individual radio button prompts.

 The FUNCTION character expression expC1 must begin with *R. To create the radio button prompts, include a space after *R followed by a list of the prompts separated by semicolons. One button is created for each prompt. For example, the following FUNCTION clause creates three radio buttons with the prompts None, Single and Double:

 ... FUNCTION '*R None;Single;Double' ...

 The PICTURE character expression expC2 uses the same syntax as the FUNCTION expression except the PICTURE expression must begin with @ followed by *R. For example, the following PICTURE clause creates three radio buttons with the prompts None, Single and Double:

 ... PICTURE '@*R None;Single;Double' ...

 You can also include both the FUNCTION and PICTURE clauses to create radio buttons. If both are included, the FUNCTION character expression expC1 must contain *R to create the radio buttons and can also include a space and some radio button prompts. The PICTURE character expression expC2 can include prompts to create additional radio buttons.

 The following examples illustrate the various forms of syntax you can use to create a set of radio buttons. The radio buttons begin in the second row and second column. Three radio buttons are created with the prompts None, Single and Double. A number corresponding to the button chosen is stored to the memory variable MCHOICE.

 FUNCTION clause only:

 STORE 1 TO mchoice
 @ 2,2 GET mchoice FUNCTION '*R None;Single;Double'
 READ

 STORE 1 TO mchoice
 STORE '*R None;Single;Double' TO mfunc
 @ 2,2 GET mchoice FUNCTION mfunc
 READ

 PICTURE clause only:

 STORE 1 TO mchoice
 @ 2,2 GET mchoice PICTURE '@*R None;Single;Double'
 READ

 FUNCTION and PICTURE clause:

 STORE 1 TO mchoice
 @ 2,2 GET mchoice FUNCTION '*R' PICTURE ' None;Single;Double'
 READ

 STORE 1 TO mchoice
 @ 2,2 GET mchoice FUNCTION '*R None;Single' PICTURE ';Double'
 READ

Radio Buttons with Picture Prompts
 In FoxPro for Windows and FoxPro for Macintosh, the prompt for a radio button can also be the name of a picture file. In FoxPro for Macintosh, you can use a picture file of PICT type or a .BMP bitmap file.

 When a radio button uses a picture file for a prompt, the radio button mimics the behavior of a radio button with a text prompt. For example, the picture file appears but the radio button isn't displayed. Like choosing a radio button, choosing the picture prompt stores the radio button's value to memvar or field.

 To use a picture file in a radio button, add B to the radio button specification code. The FUNCTION and PICTURE clause specification codes that create a radio button are *R and @*R, respectively. To create a radio button with picture prompts, use the codes *RB and @*RB, followed by a space and the picture filename. If the picture file is not located in the default directory or folder, include the path to picture file with the picture filename.

 -------------------------------
 Note - The pictures aren't clipped, reduced or enlarged to fit the radio button. Use the SIZE clause to adjust the size of the radio buttons to accommodate the pictures.
 -------------------------------
 
 If you omit the extension for the picture file, FoxPro for Macintosh first looks for a picture file with the name you specified and a .BMP extension. If a picture file with a .BMP extension and the name you specified isn't found, FoxPro for Macintosh then looks for a file with the name you specified and a .PCT extension. If a picture file with a .PCT extension and the name you specified isn't found, FoxPro for Macintosh then looks for a picture file with the name you specified without an extension.

Picture Masks and Radio Buttons
 In FoxPro for Windows and FoxPro for Macintosh, a picture radio button has three states: up, down and disabled. FoxPro automatically controls the appearance a picture radio button when it is in each of these three states, but you can override the default appearance by using a picture mask.

 A mask is used to control the transparent areas of a picture radio button. By default, the white areas are transparent. If a mask is present, the white areas of the mask, not the picture file, are transparent.

 A mask is a monochrome picture file. In FoxPro for Windows, a mask is a .BMP with an .MSK extension. In FoxPro for Macintosh, a mask can be a .BMP with an .MSK extension or a PICT type file with a .PCM extension. The mask must have the same base name as the picture file and the appropriate extension. FoxPro automatically looks for a mask for a picture file in the same directory or folder where the picture file is located.

 In most cases, a mask isn't necessary. If you don't need anything in your picture to appear white or your picture file has a white background, the picture radio button will appear as desired in the up, down and disabled states.

 When a picture radio button has a mask and is in the up or down state, any white areas in the picture file appear transparent, allowing the color of the button face to show through. However, you can maintain the white color of certain areas. Suppose that you have a picture file with a dog on a white background; the dog has white eyes and the button face is red. You want the background of the button to appear red but you want the dog's eyes to be white, not red. Make a mask that is the same size as the picture file but includes only two colors, black and white. Leave the background of the mask white but make the dog - including his eyes- completely black. When the button appears, the background is red to match the button face but the dog's eyes are white.

 When a picture radio button is disabled, any white areas in the picture file appear transparent so the color of the button face shows through. Any non-white areas appear dark gray. If the button has a mask, all white areas in the mask are transparent so the color of the button face shows through, and all black areas appear dark gray.

PICTURE and FUNCTION Options N, T, H, V, 2 and 3
 Additional options can be combined with the *R specification code to modify the behavior (N and T) and appearance (H, V, 2 and 3) of radio buttons.

 The 2 (two-dimensional) and 3 (three-dimensional) specification codes are only available in FoxPro for Macintosh.

 Option Description

  N Does not terminate the READ when a radio button is chosen. This is the default behavior.

  T Terminates the READ when a radio button is chosen.

  H Positions the radio buttons in a horizontal row.

  V Positions the radio buttons in a vertical column. This is the default orientation.

  2 Creates flat (two-dimensional) radio buttons identical to radio buttons in Macintosh dialogs. This is the default radio button type in FoxPro for Macintosh.

  3 Creates three-dimensional radio buttons identical to radio buttons in FoxPro for Macintosh dialogs.

 You can combine the T or N options with the H or V and 2 or 3 options. For example, the following clause creates a vertical row of radio buttons and doesn't cause the READ to terminate when a button is chosen:

 ... FUNCTION '*RNV ... '

 In FoxPro for Macintosh, the following clause creates a vertical row of two-dimensional radio buttons and doesn't cause the READ to terminate when a button is chosen:

 ... FUNCTION '*RNV2 ... '

Radio Buttons with Special Features
 You can assign a hot key to a radio button or disable a radio button. To assign these special features to a radio button, you must include special characters when defining the prompt. The special characters are removed when the prompt is stored to memvar or field.

Hot Keys
 In FoxPro for MS-DOS, a hot key is a highlighted letter in a radio button prompt that you can type to immediately choose the radio button. Pressing the hot key selects the radio button and chooses it. To assign a hot key, place a backslash and a less-than sign (\<) before the desired character of the radio button prompt.

 A hot key doesn't choose the radio button if the current object is a GET field, a text-editing region, a popup or a list.

 If the current object is an @ ... GET input field or a text-editing region, pressing the hot key enters the character in the field or the text-editing region. If the current object is a pop-up or a list, pressing the hot key selects the first option in the popup or list whose prompt begins with the hot key character.

 In FoxPro for Windows, a hot key is an underlined letter in the radio button prompt that you can type to immediately choose the radio button. If the current object is an @ ... GET input field, a text-editing region, a popup or a list and KEYCOMP is set to WINDOWS, you can press the Alt key and the hot key to choose the radio button.

 In FoxPro for Macintosh, the KEYCOMP setting determines if hot keys are underlined. If KEYCOMP is set to DOS or WINDOWS, hot keys are underlined. If KEYCOMP is set to MAC, hot keys are not underlined but are still available.

 The following example creates three radio buttons with the prompts None, Single and Double and assigns the hot keys N to None, S to Single and D to Double:

 STORE 1 TO mchoice
 @ 2,2 GET mchoice FUNCTION '*R' PICTURE '\<None;\<Single;\<Double'
 READ

Disabled Radio Buttons
 You can disable a radio button so it can't be selected or chosen. Disabled buttons are shown in disabled colors. To disable a single radio button, place two backslashes (\\) before the button's prompt. To disable a set of radio buttons, use DISABLE, which is discussed later in this section.

 The radio button with the prompt Single is disabled in this example:

 STORE 1 TO mchoice
 @ 2,2 GET mchoice FUNCTION '*R' PICTURE 'None;\\Single;Double'
 READ

FONT expC3 [, expN1]
 The character expression expC3 is the name of the font, and the numeric expression expN1 is the font size. For example, the following clause can be used to display the radio button prompts in 16-point Courier font:

 FONT 'Courier', 16

 If you include the FONT clause but omit the font size expN1, a 10-point font is used.

 In FoxPro for Windows, if the font you specify is not available, a font with similar font characteristics is substituted.

 In FoxPro for Macintosh, if the font you specify is not available, the Chicago font is used.

 In FoxPro for MS-DOS, the FONT clause is ignored.

 If the FONT clause is omitted and the radio buttons are placed in the main FoxPro window, the main FoxPro window font is used. If the FONT clause is omitted and the radio buttons are placed in a user-defined window, the user-defined window font is used.

STYLE expC4
 In FoxPro for Windows and FoxPro for Macintosh, include the STYLE clause to specify a font style for the radio button prompts. If the font style you specify is not available, a font style with similar characteristics is substituted.

 The font style is specified with expC4. If the STYLE clause is omitted, the normal font style is used.

 Character Font Style
 --------- ----------
 
  B  Bold

  C  Condense*

  E  Extend*

  I  Italic

  N  Normal

  O  Outline

  Q  Opaque

  S  Shadow

  -  Strikeout*

  T  Transparent

  U  Underline

 * The Condense and Extend styles are only available in FoxPro for Macintosh. The Strikeout style is only available in FoxPro for Windows.


 You can include more than one character to specify a combination of font styles. For example, the following clause specifies Bold Italic:

 STYLE 'BI'

 The STYLE clause is ignored in FoxPro for MS-DOS.

DEFAULT expr
 When you choose a radio button, your choice is saved in the memory variable, array element or field you specify. If you specify a memory variable that doesn't exist, it is automatically created and initialized if you include the DEFAULT clause. However, an array element isn't created if you specify an array element in a DEFAULT clause. The DEFAULT clause is ignored if the memory variable already exists or you specify a field.

 If the DEFAULT clause isn't included and memvar doesn't exist, the error message "Variable not found" appears.

 The DEFAULT expression expr determines the type of memory variable created and its initial value. expr must be of numeric or character type. Here are examples of DEFAULT clauses for radio buttons:

 @ 2,2 GET mchoice FUNCTION '*R' + ;
  'None;Single;Double' DEFAULT 'Single'
 READ

 @ 2,2 GET mchoice FUNCTION '*R None;Single;Double' ;
  DEFAULT 2
 READ

SIZE expN2, expN3 [, expN4]
 The size expN2 clause specifies the height in rows of the radio buttons. In FoxPro for MS-DOS, a radio button is always one line high, so the numeric expression expN2 is ignored.

 By default, the width of each individual button is determined by the length of the radio button prompt text. expN3 specifies the width (in columns) of each radio button.

 By default, no rows are placed between vertical buttons and a single column is placed between horizontal buttons. The spacing between radio buttons in rows is specified with expN4.

 In FoxPro for Windows and FoxPro for Macintosh, the radio button font determines the size of the editing region. The radio button font is specified with the FONT clause. If the FONT clause is omitted, the radio buttons use the font of the parent window (the main FoxPro window or a user-defined window).

 This example demonstrates how the SIZE clause control's the button spacing:

 CLEAR
 @ 2,2 GET mchoice1 FUNCTION '*R'+ '\<None;\<Single;\<Double' ;
  DEFAULT 'None' SIZE 1, 12, 1
 @ 2,16 GET mchoice2 FUNCTION '*R'+ '\<None;\<Single;\<Double' ;
  DEFAULT 'None' SIZE 1, 12, 3
 READ

ENABLE | DISABLE
 Radio buttons are by default enabled when READ or READ CYCLE is issued. You can prevent a set of radio buttons from being selected when READ or READ CYCLE is issued by including DISABLE.

 Disabled radio buttons cannot be selected and are displayed in the disabled colors. To disable individual radio buttons instead of an entire set, see "Disabled Radio Buttons" earlier in this section. Use SHOW GET ENABLE to enable a set of disabled radio buttons.

MESSAGE expC5
 The MESSAGE clause character expression expC5 appears when a radio button is selected. In FoxPro for MS-DOS the message is by default centered on the last line of the main FoxPro window. The message location can be changed with SET MESSAGE.

 In FoxPro for Windows and FoxPro for Macintosh, the message is placed in the graphics-based status bar. If the graphics-based status bar has been turned off with SET STATUS BAR OFF, the message is placed on the last line of the main FoxPro window.

VALID expL1 | expN5
 You can include an optional VALID expression expL1 or expN5 that is evaluated when a radio button is chosen. That is, VALID isn't evaluated when you select (move to) a radio button, but when you actually choose the radio button by pressing Enter, Spacebar or clicking on the radio button.

 Typically, expL1 or expN5 is a user-defined function (UDF). With a user-defined function (UDF) you can select, enable or disable other objects, open a Browse window, open another data-entry screen or move to a new record. CLEAR READ can be included in the user-defined function to terminate the READ.

 expL1
  When a logical value is returned to the VALID clause, the logical value is ignored and the radio buttons remain the active control. However, you can specify a UDF that returns a logical value to the VALID clause and activates another object.

 expN5
  A VALID clause that includes a numeric expression is used to specify which object is activated after a radio button is chosen. Objects are @ ... GET input fields, check boxes, lists, popups, spinners, text-editing regions and each individual button in a set of push, radio and invisible buttons.

 The expression expN5 has one of three effects:

  When expN5 = 0, the chosen radio button remains the active button.

  When expN5 is positive, expN5 indicates the number of objects to advance. For example, when the last radio button in a set of radio buttons is selected and VALID returns 1, the next object is activated. If expN5 is greater than the number of remaining objects, the READ is terminated (unless READ CYCLE is issued to activate the objects).

  When expN5 is negative, expN5 indicates the number of objects to move back. For example, when the first radio button in a set of radio buttons is selected and VALID returns -1, the previous object is activated. If expN5 moves back past the first object, the READ is terminated (unless READ CYCLE is issued to activate the objects).

WHEN expL2
 The WHEN clause allows or prohibits selection of a set of radio buttons based on the logical value of expL2, which must evaluate to a logical true (.T.) before the radio buttons can be selected. If expL2 evaluates to a logical false (.F.), the radio buttons cannot be selected and are skipped over if placed between other objects.

COLOR SCHEME expN6 | COLOR color pair list
 If you do not include a COLOR clause, radio button colors are determined by the color scheme for the main FoxPro window; if radio buttons are placed in a user-defined window, the window's color scheme determines the radio button colors.

 The colors of radio buttons can be specified by including the number of an existing color scheme in the COLOR SCHEME clause or a set of color pairs in the COLOR clause.

 A color scheme is a set of 10 predefined color pairs. The color pairs in a color scheme can be changed with SET COLOR OF SCHEME. In FoxPro for MS-DOS the color pairs in a color scheme can also be changed in the Color Picker.

 A color pair is a set of two letters separated by a forward slash. The first letter specifies the foreground color and the second letter specifies the background color.

 For example, this color pair specifies a red foreground on a white background:

 R/W

 For a list of colors and their corresponding color letters, see SET COLOR Overview or Color Table by Color Pair.

 A color pair can also be specified with a set of six RGB (Red Green Blue) color values separated by commas. The first three color values specify the foreground color and the second three color values specify the background color. The color values can range from 0 through 255.

 The R/W color pair in the example above can also be specified with this RGB color pair:

 RGB(255,0,0,255,255,255)

 The following table lists the color pairs and what each color pair in the list controls.

 Color Pair  Radio Button
  Number   Attribute
 ----------  ------------

  5   Message

  6   Selected radio prompt

  7   Hot keys

  9   Enabled radio prompt

  10   Disabled radio prompt

 This example shows how to override one color scheme with another predefined color scheme:

 STORE 1 TO mchoice
 @ 2,2 GET mchoice FUNCTION '*R None;Single;Double';
  COLOR SCHEME 4
 READ

 The following example creates None, Single and Double radio buttons with the hot keys N for None and S for Single. In addition, the buttons have the following color characteristics:

  The selected button is shown with a bright white prompt on a blue background (W+/B).

  Hot key characters are shown in red on a blue background (R/B).

  Enabled buttons are shown with a yellow prompt on a blue background (GR+/B).

  Disabled buttons are shown with a white prompt on a blue background (W/B).

 When you skip a color pair, you must include a comma where the color pair is omitted.

 Here are the commands:

 STORE 1 TO mchoice
 @ 2,2 GET mchoice FUNCTION '*R \<None;\<Single;\\Double';
  COLOR ,,,,,W+/B,R/B,,GR+/B,W/B
 READ

Expand imageRemarks

Expand imageExample

Expand imageSee Also


© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic