input for input (2) 
Author Message
 input for input (2)

Hy there.

I want to be able to edit an existing string in Qbasic. I haven't found a
simple way to 'feed' the string to INPUT. (INPUT A$ < "hello world.")

I tried to put the sting on the keyboard-buffer (0x41E-0x43d) but I got
stuck again. I can't find a way to convert a Character to its
keyboard-scancode.

Is there a way to do this?

Thanks!

(the original message was posted as reply to an existing mail. error!
This one's better!)



Mon, 30 Nov 1998 03:00:00 GMT  
 input for input (2)

On Thu, 13 Jun 1996 04:40:50 -0700, Thomas Leemans

Quote:

>Hy there.

>I want to be able to edit an existing string in Qbasic. I haven't found a
>simple way to 'feed' the string to INPUT. (INPUT A$ < "hello world.")

>I tried to put the sting on the keyboard-buffer (0x41E-0x43d) but I got
>stuck again. I can't find a way to convert a Character to its
>keyboard-scancode.

>Is there a way to do this?

If dirt had the same IQ as INPUT$ weeds wouldn't grow in it!

What you need to do is build a small, simple, field input routine that
you can send your string(s) to for editing.

FUNCTION fINPUT$( Row%, Col%, Cols%, D$ )

END FUNCTION

Have your function return the last key-press, ENTER, ESC, UP, DOWN,
etc. so you can, later, build a multi-field editor that works with
arrays.

  ____    _    ____      ____  _____
 |  _ \  / \  / ___) __ | ___)(_   _) | Don Schullian
 | |_)  / _ \ \____\/  \|  _)   | |   |  Gramou 33
 |____//_/ \_\(____/\__/|_|     |_|   |  Papagou, 156-69
 ___________________________________  |  Greece
  =================================== |  ++30-1-654-6200

   -----------======### DOWNLOAD ###=========------------
            Nutz 'n Boltz for powerbasic v3.2  
              A library of everyday goodies
   DOWNLOAD N-B-V201.ZIP FROM YOUR FAVORITE SITE TODAY!



Mon, 30 Nov 1998 03:00:00 GMT  
 input for input (2)

Quote:

> If dirt had the same IQ as INPUT$ weeds wouldn't grow in it!

> What you need to do is build a small, simple, field input routine that
> you can send your string(s) to for editing.

> FUNCTION fINPUT$( Row%, Col%, Cols%, D$ )

> END FUNCTION

> Have your function return the last key-press, ENTER, ESC, UP, DOWN,
> etc. so you can, later, build a multi-field editor that works with
> arrays.

Yes, that's it! (why didn't I think of that! :-)
Do you / does anybody have this function already? I expect it's a lot of
programming to make all the keys work (backspace, del, end, home, tab,
ins).
Thanks!


Tue, 01 Dec 1998 03:00:00 GMT  
 input for input (2)

G'Day All

Quote:


>Subject: Re: Re: input for input
>Date: Fri, 14 Jun 1996 02:58:06 -0700

>> If dirt had the same IQ as INPUT$ weeds wouldn't grow in it!

>> What you need to do is build a small, simple, field input routine that
>> you can send your string(s) to for editing.

>> FUNCTION fINPUT$( Row%, Col%, Cols%, D$ )

>> END FUNCTION

>> Have your function return the last key-press, ENTER, ESC, UP, DOWN,
>> etc. so you can, later, build a multi-field editor that works with
>> arrays.
>Yes, that's it! (why didn't I think of that! :-)
>Do you / does anybody have this function already? I expect it's a lot of
>programming to make all the keys work (backspace, del, end, home, tab,
>ins).
>Thanks!

Heres a version that was orginally posted by  Egbert Zijlema in PowerBasic
format. I have changed it to QBASIC/QB4.x syntax and modified it slightly for
speed.

'================txtedit.bas================================
DECLARE SUB Editor (Row!, Col!, length!, text$)
DECLARE FUNCTION GetKey$ ()

' TEXTEDIT.BAS processes keyboard input
'   Author: Egbert Zijlema (NL)
'   rev. date: 22/07/95
'   Modified by Ian Musgrave 14/6/96
'   converted to QB4.x/QBASIC format and
'   some key handling changed.

' sample calling module

  CLS
  LOCATE 10, 10: PRINT "Your name: "
  LOCATE 11, 10: PRINT "Street   : "
  LOCATE 12, 10: PRINT "Village  : "
  CALL Editor(10, 21, 20, YourName$)
  CALL Editor(11, 21, 25, street$)
  Editor 12, 21, 20, village$
END

SUB Editor (Row, Col, length, text$) STATIC
  ' check for insert mode on start
  DEF SEG = 64
  ScanInsert = PEEK(23)
  IF (ScanInsert AND 128) = 128 THEN
    ins = 1
    LOCATE , , , 5, 6                             ' line cursor
  ELSE
    ins = 0
    LOCATE , , , 3, 6                             ' block cursor
  END IF
  DEF SEG

  COLOR 15, 0
  LOCATE Row, Col: PRINT text$;
  cursor = LEN(text$) + 1
  DO
    COLOR 15
    LOCATE Row, Col + cursor - 1, 1               ' visible cursor
    TextHasBeenChanged = 0
    character$ = ""
    KeyIn$ = GetKey$
    IF LEN(KeyIn$) = 1 THEN                       'Change Key to number
          KeyVal = ASC(KeyIn$)                    'for speed
    ELSE
          KeyVal = -ASC((RIGHT$(KeyIn$, 1)))  'Handle extended keys (F1, Del)
    END IF  
    SELECT CASE KeyVal

      ' normal ascii code:
      CASE 8                                     ' backspace
        IF cursor = 1 THEN
                         'do nothing
        ELSE
                text$ = LEFT$(text$, cursor - 2) + MID$(text$, cursor)
                cursor = cursor - 1
                LOCATE Row, Col
                PRINT text$; SPACE$(length - LEN(text$));
                END IF
      CASE 27                                    ' escape
        ' delete editline
        cursor = 1: text$ = ""
        TextHasBeenChanged = 1

      CASE 32 TO 125                       ' printable chars
        character$ = KeyIn$
        TextHasBeenChanged = 1

      CASE -71                                ' home
        cursor = 1

      CASE -75                                  ' left arrow
        IF cursor > 1 THEN cursor = cursor - 1

      CASE -77                                ' right arrow
        IF cursor < LEN(text$) + 1 THEN cursor = cursor + 1

      CASE -79                                 ' end
        cursor = LEN(text$) + 1

      CASE -82                                 ' toggle insert
        IF ins THEN
          ins = 0: LOCATE , , , 3, 6
        ELSE
          ins = 1: LOCATE , , , 5, 6
        END IF

      CASE -83                                 ' del
        text$ = LEFT$(text$, cursor - 1) + MID$(text$, cursor + 1)
        LOCATE Row, Col
        PRINT text$; SPACE$(length - LEN(text$));
    END SELECT
    IF TextHasBeenChanged THEN
      text$ = LEFT$(text$, cursor - 1) + character$ + MID$(text$, cursor + ABS(ins - 1))
      IF LEN(text$) > length THEN text$ = LEFT$(text$, length)
      IF cursor < LEN(text$) + 1 THEN cursor = cursor + 1
      LOCATE Row, Col
      PRINT text$; SPACE$(length - LEN(text$));
    END IF

  LOOP UNTIL KeyIn$ = CHR$(13)                        ' until <return>
                                              'Can look for other keys as well
 ' finally unbold edited text  
COLOR 7  
LOCATE Row, Col: PRINT text$;
SPACE$(length - LEN(text$))END SUB

DEFINT A-Z
FUNCTION GetKey$ STATIC

  DO
    KeyIn$ = INKEY$
  LOOP UNTIL LEN(KeyIn$)
  GetKey$ = KeyIn$
END FUNCTION

'=======end text edit============
Cheers! Ian

---------------------------------------------
Ian Musgrave Ph.D, Prince Henry's Institute of Medical Research
PO Box 5152, Clayton 3168, Australia.
Phone +61 3 550 4286 FAX +61 3 550 6125




Tue, 01 Dec 1998 03:00:00 GMT  
 input for input (2)

In many BASICs (I hesitate to say all), the INPUT command accepts
whatever it finds on the screen line at or to the right of the cursor
position at the start of the INPUT. So, rather than fiddling with POKEs
to the keyboard buffer, it is possible to put some pre-existing string
into an INPUT simply by arranging for the screen line to look like this:

Prompt?  Pre-existing string
       ^
       |
(cursor position)

All you have to do is PRINT the pre-existing string at the appropriate
position on the screen, and then locate the cursor just to the left of
it at the start of the INPUT. If the user simply hits ENTER in response
to the INPUT prompt, the pre-existing string is input. If the user types
any changes to it, these changes will go into the input. I think this is
what you want, right?

It's worth a try, anyway!

                            dow



Tue, 01 Dec 1998 03:00:00 GMT  
 input for input (2)

Quote:

> In many BASICs (I hesitate to say all), the INPUT command accepts
> whatever it finds on the screen line at or to the right of the cursor
> position at the start of the INPUT. So, rather than fiddling with POKEs
> to the keyboard buffer, it is possible to put some pre-existing string
> into an INPUT simply by arranging for the screen line to look like this:

> Prompt?  Pre-existing string
>        ^
>        |
> (cursor position)

> All you have to do is PRINT the pre-existing string at the appropriate
> position on the screen, and then locate the cursor just to the left of
> it at the start of the INPUT. If the user simply hits ENTER in response
> to the INPUT prompt, the pre-existing string is input. If the user types
> any changes to it, these changes will go into the input. I think this is
> what you want, right?

> It's worth a try, anyway!

>                             dow

I tried that but it doesn't work. Do you have any other code than this:

LOCATE 1,3
PRINT "hello world"
LOCATE 1,1
INPUT text$
LOCATE 3,1
PRINT text$

This only returns the characters the user really typed and ignores the
string.



Sun, 06 Dec 1998 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Formatting date input in Input Box

2. Input vs Input$

3. **Need Help with User INPUT, ASCII Codes, INPUT String length

4. Help: INPUT / INPUT # for gopher/UNIX files

5. API Call - Minimized App To Test Input of Mouse And Key Input

6. how to detect how long without any input since last input action

7. code similar to Qbasic INPUT and LINE INPUT keywords

8. Input# and Line Input#

9. How to disable/enable keyboard input and mouse input

10. how to detect how long without any input since last input action

11. Very Tricky: How do you block user input via hardware in Windows, while still allowing keybd_event and mouse_event calls to emulate input?

12. Very Tricky: How do you block user input via hardware in Windows, while still allowing keybd_event and mouse_event calls to emulate input?

 

 
Powered by phpBB® Forum Software