'---------------------------------------------------------------------------------------- ' Name: INPUT_ECHO.TIG ' Type: TIGER-BASIC(tm) Source Code ' Purpose: Sample of how to enter data in an input mask with generic edit functions. ' ' (C) - Copyright Wilke Technology, P.O.Box 1727, D-52018 Aachen, Germany '---------------------------------------------------------------------------------------- ' ' Thank you for using BASIC Tigers in your products. If you have questions, ideas ' or special needs, please contact your next distributor or the Tiger support team ' and visit our web site: ' ' Wilke Technology GmbH ' The Tiger Support Team ' P.O.Box 1727, D-52018 Aachen, Germany ' Krefelder Str. 147, D-52070 Aachen, Germany ' ' email: support@wilke-technology.com (english) ' email: support@wilke.de (german) ' Phone: +49 (241) 918 900 Mo to Fr, 7:00 to 16:00 (GMT) ' Fax: +49 (241) 918 9068 ' ' New information, new drivers and free downloads see: ' ' www.wilke-technology.com (english) ' www.wilke.de (german) ' ' Sincerely, ' ' Your Tiger Support Team ' '---------------------------------------------------------------------------------------- ' ' Example for a keyboard input with echo at specific position. Additionally valid ' characters and a preset value can be specified. ' passes the entered value, resets to the preset value. ' ' In principle this subroutine can be used to replace the standard INPUT function for ' entering data through a keyboard. ' '---------------------------------------------------------------------------------------- USER_VAR_STRICT ' check for variable declaration #INCLUDE KEYB_PP.INC ' keyboard layout for Plug & Play Lab #DEFINE LCD 1 TASK MAIN ' begin task MAIN BYTE X ' vars of type BYTE LONG L ' vars of type LONG REAL R ' vars of type REAL STRING S$, CSET$(127) ' vars of type STRING INSTALL_DEVICE #LCD, "LCD1.TDD" ' install LCD-driver CALL INIT_KEYB ( LCD ) ' set keyboard + var. params '---------------------------------------------------------------------------------------- ' sample for input of STRING value S$ = "First Test" ' preset value CSET$ = "" ' initialize CSET$ FOR X = 32 TO 127 ' CSET$ = CSET$ + CHR$(X) ' valid chars NEXT ' PRINT #1, "<27>A<0><0>"; ' position cursor PRINT #1, "<1>Set S$ ="; ' CALL INPUT_ECHO (0, 9, S$, CSET$) ' call input routine PRINT #1, "<27>A<0><0>"; ' position cursor PRINT_USING #1, " S$ is = "; S$; " " ' display entered value (formatted) '---------------------------------------------------------------------------------------- ' sample for input of LONG value USING "UD<9><0> V3.3.3.3.3" ' set format for output S$ = "1234" ' preset value CSET$ = "0123456789-" ' valid chars PRINT #1, "<27>A<0><1>"; ' position cursor PRINT #1, "Set L ="; ' CALL INPUT_ECHO (1, 8, S$, CSET$) ' call input routine L = VAL_NUM(S$) ' extract value from string PRINT #1, "<27>A<0><1>"; ' position cursor PRINT_USING #1, " L is ="; L; " " ' display entered value formatted '---------------------------------------------------------------------------------------- ' sample for input of REAL value USING "NF<4><0> <5>V0.0.0.0.& 0.0.1.3,5.0.0.0.0.0.0.0" ' set format for output S$ = "1.23" ' preset value CSET$ = "0123456789.-" ' valid chars PRINT #1, "<27>A<0><2>"; ' position cursor PRINT #1, "Set R ="; ' CALL INPUT_ECHO (2, 8, S$, CSET$) ' call input routine R = VAL_REAL(S$,".") ' extract value from string PRINT #1, "<27>A<0><2>"; ' position cursor PRINT_USING #1, " R is ="; R; " " ' display entered value formatted END ' end of task MAIN '---------------------------------------------------------------------------------------- ' Subroutine INPUT_ECHO reads input from keyboard with echo ' ' Parameters: X starting line on LCD ' Y starting column on LCD ' IN$ preset value ' CS$ set of valid characters '---------------------------------------------------------------------------------------- SUB INPUT_ECHO (BYTE X,Y; VAR STRING IN$,CS$) STRING CH$, OLDIN$ ' LONG N, FLAG, EXIT ' OLDIN$ = IN$ ' save old string FLAG = 0 ' initialize flag EXIT = 0 ' initialize exit flag CH$ = "" ' initialize string PRINT #1, "<27>c<1>"; ' switch cursor on WHILE NOT EXIT = 1 ' while not or PRINT #1, "<27>A";CHR$(Y);CHR$(X);""; ' position cursor PRINT #1, IN$;" <8>"; ' print current string FOR N = 0 TO 0 STEP 0 ' endless loop until N=1(GET!) GET #1, #0, #1, 1, N ' N = no. of chars in keyboard buffer NEXT ' end of endless loop GET #1, 1, CH$ ' read 1 char from keyboard buffer FLAG = INSTR(CH$,CS$,0,0) ' check for valid char IF FLAG <> -1 THEN ' if valid char IN$ = IN$ + CH$ ' append to string ENDIF ' IF CH$ = "<8>" THEN ' if backspace IN$ = LEFT$(IN$, LEN(IN$)-1) ' delete last char from string ENDIF ' IF CH$ = "<13>" THEN ' if return EXIT = 1 ' set exit flag ENDIF ' IF CH$ = "<27>" THEN ' if escape IN$ = OLDIN$ ' restore old string EXIT = 1 ' set exit flag ENDIF ' ENDWHILE ' PRINT #1, "<27>c<0>"; ' switch cursor off END ' end of task INPUT_ECHO