The free form menu mode (opcode MMO'FFM) can be used to create Dialog Boxes with Radio Buttons. A Dialog Box is a box or window which pops up on the screen in response to some sort of condition requiring the operator's immediate attention. A typical example would be to pop up a message warning the operator that you are about to print a report requiring a special form. In order to be considered a Dialog Box, some sort of operator response is generally required. In this example, possible responses might be to proceed, abort, or print an alignment. When the response can be expressed in terms of a multiple-choice question, a common interface technique is to use Radio Buttons, which allow the operator to select one of the choices graphically. (The term Radio Buttons derives from the old-fashioned car radio station pre-select buttons, where there are a number of choices but only one can be picked at a time.).
To create the type of Dialog Box with Radio Buttons described above, we might set the parameters as follows:
DIALOG'BOX:
OPCODE = MMO'BDR + MMO'SVA + MMO'RSA + MMO'FFM
CHANNEL = 0
STROW = 10 : STCOL = 15 : ENDROW = 15 : ENDCOL = 65
TEXT = "~" + chr$(13) + &
" Please mount form CHECKS in printer LPT0 "
TEXT = TEXT + chr$(13) + chr$(13) + &
"[Ready] [Abort] [Print Alignment Pattern]"
xcall INMEMO, OPCODE, TEXT, CHANNEL, STROW, STCOL, &
ENDROW,ENDCOL, LINK,XPOS,VSPEC,MMOCLR,EXTCTL
if EXTCOD = MME'SAF call REPAINT'SCREEN
if TEXT = "Ready" goto PROCEED &
else if TEXT = "Abort" goto ABORT &
else if TEXT = "Print Alignment Pattern" call ALIGN
goto DIALOG'BOX
Notes: We used the MMO'FFM opcode to activate the free form menu mode, and we used MMO'SVA and MMO'RSA to save and restore the screen area used. (After the xcall, we tested EXTCOD for the error flag indicating if the save/restore worked. If not, we called a routine to repaint the screen manually. This may or may not be necessary or desirable depending on the situation.) Since we were building the Dialog Box directly in the TEXT parameter, we set CHANNEL to zero. The TEXT parameter started with a tilde (~) since we didn't see any need for a top title. This was followed by a blank line, a message, a blank line, and the three choices. Note that the brackets [] are the default menu item delimiters - we could have changed them using the EXTSMI and EXTEMI fields with EXTCTL.
In this case, we did our own formatting by including carriage returns as necessary. If the text message was longer than the memo width, INMEMO would have done the necessary word wrapping itself. Note however, that you cannot rely on INMEMO to properly wrap lines containing actual menu selections, unless none of the selections contains any spaces. Free form menus can scroll horizontally, but each item must begin and end on the same line. Items with spaces in them (like the third choice above) might be split over two lines if you left the formatting up to INMEMO's word wrap, causing the menu to malfunction.
On exit, we simply check for the possible responses. Note that the menu item delimiters (brackets in this case) are not returned as part of the item. Also note that the user can abort from these boxes by hitting Escape or ^C, which would cause nothing to be returned in TEXT. In the example above, this would cause the program to fall through the "if" statement and then go back to the top, displaying the Dialog Box over again. Depending on your requirements, you may want to treat this type of abort the same as selecting the [Abort] button.