TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ALL
from: SAM PAULSON
date: 1995-10-08 02:26:00
subject: SUB GetInput

I came up with the following SUB as a replacement to using INPUT,
but I'm having problems with it putting a colored character down
further on the screen from where the input is entered.  I'd
appreciate it if someone could run this little example and let me
know what's wrong with the code, or maybe just provide me with a
better replacement....
CLS : LOCATE 1, 1
PRINT "What is your name?"
GetInput 1, 20, 15, 1, 5
COLOR 7, 0
SUB GetInput (LineNumber, Row, ForeGround, BackGround, LenAnswer)
   SHARED answer$
   answer$ = ""
   DO
      DO
 KeyPressed$ = INKEY$
 y = (LEN(answer$) + Row)
 COLOR ForeGround + 16, BackGround: LOCATE LineNumber, y
 PRINT "_";     'the cursor
 COLOR 15, 1
      LOOP WHILE KeyPressed$ = ""
      SELECT CASE KeyPressed$
 CASE CHR$(32) TO CHR$(126)      'spacebar to ~
    IF (LEN(answer$) < LenAnswer) THEN answer$ = (answer$ + KeyPressed$)
    COLOR ForeGround, BackGround: LOCATE LineNumber, Row
    PRINT answer$;
 CASE CHR$(13)                   'enter key
    LOCATE LineNumber, y: PRINT " ";     'erase cursor after enter is pr
    EXIT SUB
 CASE CHR$(8)                    'backspace key
    IF answer$ > "" THEN
       rowNumber = CSRLIN: col = POS(0)
       LOCATE rowNumber, col - 1
       PRINT " "
       LOCATE rowNumber, col - 1
       answer$ = MID$(answer$, 1, LEN(answer$) - 1)
    END IF
      END SELECT
   LOOP
END SUB
--- WILDMAIL!/WC v4.12 
---------------
** A related thread FOLLOWS this message.

FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC   Ref: CEFI0403 Date: 10/11/95
From: KURT KUZBA                                            Time: 02:06pm
\/To: SAM PAULSON                                         (Read 5 times)
Subj: R: SUB GetInput

SP>   I'm having problems with it putting a colored character down
SP>   further on the screen from where the input is entered.
SP>   let me know what's wrong, or maybe just a replacement....
sp>...............................................................
   Here is one with a few extra bells and whistles.
'_|_|_|   GETSTR.BAS
'_|_|_|   This program demonstrates the use of a string editing
'_|_|_|   FUNCTION. Keys allowed include all alphanumeric, RETURN,
'_|_|_|   ESCAPE, LEFT ARROW, RIGHT ARROW, HOME, END, BACKSPACE,
'_|_|_|   DELETE, and INSERT. (Insert ON is default)
'_|_|_|   Released to the   Public Domain   by Kurt Kuzba
'_|_|_|
CLS
INPUT "Hit RETURN to begin", answer$
answer$ = GetStr$ ("What is your name? ", 10, 20, 15, 1, 16)
COLOR 7, 0: PRINT answer$
FUNCTION GetStr$ (Prompt$, Xpos%, Ypos%, TextColor%, BackColor%, Limit%)
   X% = CSRLIN: Y% = POS(0): T$ = STRING$(Limit%, " "): Ins% = 1
   C% = 0: LOCATE Xpos%, Ypos%: COLOR TextColor%, BackColor%
   PRINT Prompt$; : Ypos% = POS(0)
   WHILE K$  CHR$(13)
      COLOR TextColor%, BackColor%: LOCATE Xpos%, Ypos%: PRINT T$
      LOCATE Xpos%, Ypos% + C%: COLOR 4, 7
      PRINT MID$(T$, C% + 1, 1)
      LOCATE Xpos%, Ypos% + C%, Ins%, 13, 13
      K$ = "": WHILE K$ = "": K$ = INKEY$: WEND
      IF LEN(K$) = 1 THEN K% = ASC(K$): ELSE K% = -ASC(MID$(K$, 2))
      SELECT CASE K%
      CASE 32 TO 126  'AlphaNumeric
         IF Ins% > 0 THEN
            T$ = LEFT$(LEFT$(T$, C% + 1) + MID$(T$, C% + 1), Limit%)
         END IF
         MID$(T$, C% + 1) = CHR$(K%): C% = C% -((C% + 1) < Limit%)
      CASE 8                                        'Backspace
         IF C% > 0 THEN
            C% = C% - 1: T$ = LEFT$(T$, C%) + MID$(T$, C% + 2) + " "
         END IF
      CASE 13 : PRINT                               'RETURN
      CASE 27 : txt$ = " ": K$ = CHR$(13)           'ESCAPE
      CASE -82 : Ins% = ABS(Ins% - 1)               'Insert
      CASE -75 : C% = (C% + Limit% - 1) MOD Limit%  'Cursor Left
      CASE -77 : C% = (C% + 1) MOD Limit%           'Cursor Right
      CASE -71 : C% = 0                             'Home
      CASE -79 : C% = LEN(RTRIM$(T$))               'End
         C% = C% + (C% = Limit%)
      CASE -83                                      'Delete
         T$ = LEFT$(T$, C%) + MID$(T$, C% + 2) + " "
      END SELECT
   WEND
   LOCATE X%, Y%
   GetStr$ = RTRIM$(T$)
END FUNCTION
'_|_|_|   end GETSTR.BAS

---
> ] Their only crime was being delicious........................

---------------
>>>>>>>>>>>>>>>>>>>>>> LAST Message In Thread <<<<<<<<<<<<<<<<<<<<<<

FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC   Ref: CED00001 Date: 10/08/95
From: JAMES GOLDBLOOM                                       Time: 01:07pm
\/To: KURT KUZBA (Rcvd)                                   (Read 6 times)
Subj: Re: MEMORY BUFFER

KK->    Any area allocated to your application is safe.
KK-> Try running this short program as an example.
KK-> '_|_|   BUFALLOC.BAS
Bless you, sir!
That was extremely helpful.  Thanks again, Kurt!
:-)
-James
--- QuickBBS 2.80 GoldBase (Zeta-1)
---------------
* Origin: City Lights (1:282/108.0)
* Origin: AD Message BBS/10th Year Online! (703)998-2958 (1:109/611@FIDONET)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.