Please enable JavaScript to view this site.

A-Shell Reference

Navigation: Subroutines > INFLD > INFLD Parameters > type > GUI-Related Codes

Convert Y/N Field To Checkbox

Scroll Prev Top Next More

Updated April 2019

[ Type code = ||c ] The text message associated with the checkbox must be placed in the setdef parameter, and the xmax parameter should be expanded to allow for the combined width of the text message (prompt or label) and the checkbox itself. Checkboxes may be toggled with the space bar, or set using the same keystrokes as for regular Y/N fields (i.e. either 1/0 for affirmative/negative, or by using the single-character affirmative/negative keys defined in the language definition file). They also return to the program the same field contents as they would have for normal Y/N fields, thus making it quite easy to convert existing Y/N fields to checkboxes.

The ||b code may be added so that the checkbox internal state stays in sync with its visual state, which might otherwise be changed outside the program's knowledge. Without the ||b code, clicking on the checkbox field from another context will send the field's clickcode, allowing the program to activate the field. But it also would reset the checkbox status to that prior to the click, thus resulting in the need to click twice on the checkbox to change it: once to select the field and then again to toggle it.

The color of the text label associated with the checkbox is determined by the OFCLR and OBCLR fields within the infclr parameter. In Windows themed environments, you'll need to add 64 to the OFCLR/OBCLR values to override the theme color. In most cases, you should just set all of the infclr fields to -2 for maximum compatibility with the standard Windows color logic.

By default, the text label goes on the left and the checkbox itself on the right. This can be reversed with the type R which is normally used for right justification. But in either case, the text itself is left-justified within the space allotted to it. To right justify the text within its space, add SBR=INFLDCBRJ to miame.ini.

Checkboxes are somewhat unusual, compared to typical INFLD uses, in that a single call combines both the text prompt and the data field. If your programming style divides the functions of displaying the text prompts and the data, you may want to modify the code that previously printed the text label to use INFLD opcode 2 to display both the label and checkbox contents at the same time. Having done this, you can leave the xmax parameter for the checkbox editing call set at 1 (as it would have been for a Y/N field); INFLD will recognize that it overlays an existing checkbox control object and use the existing one.

See also Checkbox Alignment, Justification.