1 SUB SMG_ONE_CHAR(STRING Prompt,LONG Row,LONG Col,STRING Inpstr, & LONG Timeout,BYTE Echo_flag,BYTE Vir_disp_num) !---------------------------------------------------------------& ! & ! SMG_ONE_CHAR & ! & ! Creation Date: 3-July-1985 & ! Author: Ken Messer & ! Purpose: Input a one character string & ! without following with a CR & ! & ! 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" DECLARE WORD Term_code DECLARE LONG RS, & Readcol, & Display_rows, & Display_cols, & Def_disp_attr, & Def_video_attr EXTERNAL LONG CONSTANT SS$_Normal 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$Change_rendition 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,,,,) & UNLESS Prompt = "" 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 reverse video RS = SMG$Change_virtual_display(Display_id(Vir_disp_num), & Display_rows,Display_cols,Def_disp_attr,Input_Display_attr,) IF RS AND SS$_Normal = 0 THEN PRINT Get_Error_Message(RS) STOP END IF 400 ! print the paint character RS = SMG$Put_chars(Display_id(Vir_disp_num), & string$(1,ASCII(paint_char)),Row,Readcol,,,,) IF RS AND SS$_Normal = 0 THEN PRINT Get_Error_Message(RS) STOP END IF Position_cursor: 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 Get_input: 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 0 to 12,14 to 31,127 ! don't allow these RS = SMG$Ring_bell(Display_id(Vir_disp_num),) GOTO Position_cursor CASE 13 ! carriage return Inpstr = "" CASE 32 TO 126 ! one valid character received Inpstr = CHR$(Term_code) ! if echo is desired, put the character back on the ! display and place the cursor on top of it IF Echo_flag <> 0 THEN RS = SMG$Put_chars(Display_id(Vir_disp_num), & Inpstr,Row,Readcol,,,,) IF RS AND SS$_Normal = 0 THEN PRINT Get_Error_Message(RS) STOP END IF 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 END IF CASE 256 TO 259 ! PF1 to PF4 Inpstr = "~PF" + NUM1$(Term_code - 255) + "~" CASE 260 TO 269 ! application Keypad Keys Inpstr = "~KP" + NUM1$(Term_code - 260) + "~" CASE 270 Inpstr = "~ENTER~" CASE 271 Inpstr = "~MINUS~" CASE 272 Inpstr = "~COMMA~" CASE 273 Inpstr = "~PERIOD~" CASE 274 Inpstr = "~UP~" CASE 275 Inpstr = "~DOWN~" CASE 276 Inpstr = "~LEFT~" CASE 277 Inpstr = "~RIGHT~" CASE 286 TO 294, 297 TO 300 Inpstr = "~F" + NUM1$(Term_code - 280) + "~" CASE 295 Inpstr = "~HELP~" CASE 296 Inpstr = "~DO~" CASE 311 Inpstr = "~FIND~" CASE 312 Inpstr = "~INSERT HERE~" CASE 313 Inpstr = "~REMOVE~" CASE 314 Inpstr = "~SELECT~" CASE 315 Inpstr = "~PREV SCREEN~" CASE 316 Inpstr = "~NEXT SCREEN~" CASE 509 ! Timeout - flag it back as having happened Timeout = -1 Inpstr = "" END SELECT 32000 Timeout = 0 UNLESS Timeout = -1 ! turn input display attribute off RS = SMG$Change_rendition(Display_id(Vir_disp_num),Row,Readcol, & 1,1,Input_display_attr,Input_display_attr) IF RS AND SS$_Normal = 0 THEN PRINT Get_Error_Message(RS) STOP END IF ! change default 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 32767 SUBEXIT END SUB