1 FUNCTION BYTE SMG_YES_NO(STRING Prompt,LONG Row,LONG Col, & BYTE Default_Response,LONG Timeout,BYTE Vir_disp_num) !---------------------------------------------------------------& ! & ! SMG_YES_NO & ! & ! Creation Date: 2-Oct-1985 & ! Author: Ken Messer & ! Purpose: Prompt user with a yes/no & ! question and take yes, no, or & ! a supplied default response as & ! input. & ! & ! Modification history & ! & ! Date Description of change(s) & ! & !---------------------------------------------------------------& ! & ! Copyright (c) 1985 - Ken Messer, Allied Electronics, Inc., & ! 401 E. 8th St., Ft. Worth, TX 76102 & ! & ! This software may be copied and distributed freely to anyone & ! for non-commerical use provided that this copyright notice is & ! included. & !---------------------------------------------------------------& OPTION TYPE = INTEGER, SIZE = INTEGER LONG %include "SMG$LIBRARY:SMG.DFN" !---------------------------------------------------------------& ! & ! D a t a D e c l a r a t i o n s & ! & !---------------------------------------------------------------& DECLARE BYTE CONSTANT Yes = -1, & No = 0 DECLARE WORD Term_code DECLARE LONG RS, & Readcol, & Display_rows, & Display_cols, & Def_disp_attr, & Def_video_attr EXTERNAL LONG CONSTANT SS$_Normal, & SMG$M_Bold EXTERNAL LONG FUNCTION SMG$Read_Keystroke, & SMG$Set_cursor_abs, & SMG$Ring_bell, & SMG$Put_chars, & SMG$Get_display_attr, & SMG$Change_virtual_display, & SMG$Erase_line EXTERNAL STRING FUNCTION Get_Error_Message(LONG) !---------------------------------------------------------------& ! & ! M a i n P r o g r a m L o g i c & ! & !---------------------------------------------------------------& ! Set up the input string read column SELECT LEN(Prompt) CASE 0 Readcol = Col CASE ELSE Readcol = Col + LEN(Prompt) + 1 END SELECT 100 ! print the prompt RS = SMG$Put_chars(Display_id(Vir_disp_num),Prompt,Row,Col,,,,) IF RS AND SS$_Normal = 0 THEN PRINT Get_Error_Message(RS) STOP END IF 200 ! get current default display attributes so we will know what ! to change back to later RS = SMG$Get_display_attr(Display_id(Vir_disp_num),Display_rows, & Display_cols,Def_disp_attr,Def_video_attr,) IF RS AND SS$_Normal = 0 THEN PRINT Get_Error_Message(RS) STOP END IF 300 ! make default video attribute bold reverse video RS = SMG$Change_virtual_display(Display_id(Vir_disp_num), & Display_rows,Display_cols,Def_disp_attr, & Input_Display_attr OR SMG$M_Bold,) IF RS AND SS$_Normal = 0 THEN PRINT Get_Error_Message(RS) STOP END IF Get_Input: 400 ! print the default response on the display - default to NO if ! something other than Yes or No is passed in SELECT Default_Response CASE Yes RS = SMG$Put_chars(Display_id(Vir_disp_num),"Y",Row, & Readcol,,,,) CASE ELSE RS = SMG$Put_chars(Display_id(Vir_disp_num),"N",Row, & Readcol,,,,) END SELECT IF RS AND SS$_Normal = 0 THEN PRINT Get_Error_Message(RS) STOP END IF 500 ! reset the cursor RS = SMG$Set_cursor_abs(Display_id(Vir_disp_num),Row,Readcol) IF RS AND SS$_Normal = 0 THEN PRINT Get_Error_Message(RS) STOP END IF 600 ! Do the input IF Timeout > 0 THEN RS = SMG$Read_Keystroke(Current_keyboard_id,Term_code,, & Timeout,Display_id(Vir_disp_num)) ELSE RS = SMG$Read_Keystroke(Current_keyboard_id,Term_code,,, & Display_id(Vir_disp_num)) END IF 700 SELECT Term_code CASE 13 ! carriage return SMG_YES_NO = Default_Response CASE 78,110 ! N,n SMG_YES_NO = No CASE 89,121 ! Y,y SMG_YES_NO = Yes CASE 509 ! Timeout - flag it back as having happened ! Take the default Timeout = -1 SMG_YES_NO = Default_Response CASE ELSE ! Nothing else allowed - ring bell and go back RS = SMG$Ring_bell(Display_id(Vir_disp_num),1) IF RS AND SS$_Normal = 0 THEN PRINT Get_Error_Message(RS) STOP END IF GOTO Get_Input END SELECT 32000 Timeout = 0 UNLESS Timeout = -1 ! change back to original video rendition RS = SMG$Change_virtual_display(Display_id(Vir_disp_num), & Display_rows,Display_cols,Def_disp_attr,Def_video_attr,) IF RS AND SS$_Normal = 0 THEN PRINT Get_Error_Message(RS) STOP END IF ! clear the line RS = SMG$Erase_line(Display_id(Vir_disp_num),Row,Col) IF RS AND SS$_Normal = 0 THEN PRINT Get_Error_Message(RS) STOP END IF 32767 EXIT FUNCTION END FUNCTION