1 SUB SMG_ONE_CHAR_CLR(STRING Prompt,LONG Row,LONG Col, & STRING Inpstr,LONG Timeout,LONG 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) & ! & ! 8-Jan-86 Handle control characters & ! 20-Nov-86 Repaint pasteboard if ctrl-W typed & ! & !---------------------------------------------------------------& ! & ! 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 Return_status, & Readcol EXTERNAL LONG CONSTANT SS$_Normal EXTERNAL LONG FUNCTION SMG$Ring_bell, & SMG$Put_chars, & SMG$Read_Keystroke, & SMG$Set_cursor_abs, & SMG$Erase_line EXTERNAL STRING FUNCTION Get_Error_Message(LONG) EXTERNAL SUB SMG$Repaint_Screen !---------------------------------------------------------------& ! & ! M a i n P r o g r a m L o g i c & ! & !---------------------------------------------------------------& ! & ! P r o g r a m F l o w & ! & ! 1) Calculate the column where input will start based upon & ! the length (or absence) of the prompt. If a prompt & ! exists, input will start two spaces beyond its' end, & ! otherwise, it will take place at row/column. & ! 2) Display the prompt (if any) at the location specified & ! by the row/column parameters. & ! 3) Display the input field paint character in reverse & ! video. & ! 4) Reset the cursor to the location calculated in step 1. & ! 5) Take the input. & ! & !---------------------------------------------------------------& Set_Up: SELECT LEN(Prompt) CASE 0 Readcol = Col CASE ELSE Readcol = Col + LEN(Prompt) + 1 END SELECT Display_Prompt: Return_status = SMG$Put_chars(Display_id(Vir_disp_num), & Prompt,Row,Col,,,,) & UNLESS Prompt = "" IF Return_status AND SS$_Normal = 0 THEN PRINT Get_Error_Message(Return_status) STOP END IF Display_Paint_Character: Return_status = SMG$Put_chars(Display_id(Vir_disp_num), & Paint_char,Row,Readcol,,Input_display_attr,,) IF Return_status AND SS$_Normal = 0 THEN PRINT Get_Error_Message(Return_status) STOP END IF Reset_Cursor: Return_status = SMG$Set_cursor_abs(Display_id(Vir_disp_num),Row,Readcol) IF Return_status AND SS$_Normal = 0 THEN PRINT Get_Error_Message(Return_status) STOP END IF Get_Input: IF Timeout < 1 THEN Return_status = SMG$Read_Keystroke(Current_keyboard_id, & Term_code,,,Display_id(Vir_disp_num),,) ELSE Return_status = SMG$Read_Keystroke(Current_keyboard_id, & Term_code,,Timeout,Display_id(Vir_disp_num),,) END IF Parse_Terminator_Code: SELECT Term_code CASE 0,27 TO 31,127 ! don't allow these Return_status = SMG$Ring_bell(Display_id(Vir_disp_num),) GOTO Reset_Cursor CASE 1 TO 12, 14 TO 22,24 TO 26 ! control keys - some of these will not work ! unless the PASTHRU characteristic is set on ! the terminal port - the port must be set NOTTYSNC ! to allow ctrl-q/ctrl-s to pass thru Inpstr = "~CTRL_" + CHR$(Term_code + 64) + "~" CASE 13 ! carriage return Inpstr = "" CASE 23 ! ctrl-W - repaint screen CALL SMG$Repaint_Screen(Current_pasteboard_id) GOTO Display_Paint_Character CASE 32 TO 126 ! one valid character received Inpstr = CHR$(Term_code) 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 Timeout = 0 UNLESS Timeout = -1 ! clear the line Return_status = SMG$Erase_line(Display_id(Vir_disp_num),Row,1) IF Return_status AND SS$_Normal = 0 THEN PRINT Get_Error_Message(Return_status) STOP END IF End_Routine: SUBEXIT END SUB