FAQ  •  Register  •  Login

Using inkey

<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Tue Jan 20, 2015 2:31 pm

Using inkey

Any one know how to do something like this

I'm looking to use inkey$ to create a line of text while the program is doing some other things Ie

LOOP
DO THING 1
INKEY(text string)
DO THING 2
IF ENTER PRINT(text String)
GOTO LOOP

any help on this
I'm always on the chat or facebook.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Tue Jan 20, 2015 3:53 pm

Re: Using inkey

ardentcrest wrote:Any one know how to do something like this

I'm looking to use inkey$ to create a line of text while the program is doing some other things Ie

LOOP
DO THING 1
INKEY(text string)
DO THING 2
IF ENTER PRINT(text String)
GOTO LOOP

any help on this


Yes, use the IN (read port) which does not interrupt.
There is a library already for this.

  Code:
#include <keys.bas>
if MultiKeys(KEYENTER) then
   PRINT "Enter pressed"
end if

Multikeys uses KEYxxxx constants (see this source at the end for available constants) and can check for several keys at once, using bOR or | (bitwise OR):
  Code:
#include <keys.bas>
if MultiKeys(KEYO | KEYZ) then
   PRINT "Key O, Key Z or both pressed"  ' letter case does not matter!
end if
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Tue Jan 20, 2015 4:15 pm

Re: Using inkey

This could be of help. for other parts of my program

But I dont think its what I'm looking for.

I want to type in a line of text while other things are happening.
I'm always on the chat or facebook.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Tue Jan 20, 2015 4:23 pm

Re: Using inkey

Have a look at INPUT.BAS code (a library to simulate INPUT)

ardentcrest wrote:This could be of help. for other parts of my program
But I dont think its what I'm looking for.

I want to type in a line of text while other things are happening.

Then you might want to store the value of INKEY$. INKEY does not lock your program execution:
  Code:
myLine = ""
row = 0

LOOP1:
  DO_THING 1
  K$ = INKEY$
  IF K$ = CHR$(13) THEN ' Enter
    LET row = row + 1
    myLine = ""
  END IF
PRINT AT row, 0; MyLine$;: REM add ; "_"; to have a cursor
GOTO LOOP1
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Tue Jan 20, 2015 4:25 pm

Re: Using inkey

ty
I'm always on the chat or facebook.
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Tue Jan 20, 2015 4:28 pm

Re: Using inkey

PS

Hope everything is working out all right for you Boriel.
I'm always on the chat or facebook.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Tue Jan 20, 2015 4:41 pm

Re: Using inkey

ardentcrest wrote:PS

Hope everything is working out all right for you Boriel.

Thanks! I will tell you later privately ;-)
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Thu Feb 19, 2015 12:42 pm

Re: Using inkey

HUMMMMM. Posts when missing :(

Need help. This compiles with no errors but still will not work. Any help.

  Code:
10 dim z$ : let z$="this is a test of an inkey$ editor                 " : gosub 2000 :stop
2000 rem INPUT+
2002 poke 23658,0 : let length=len z$
2004 for row=length to 1 step -1
2005if z$(row)=" " then CONTINUE FOR: end if : next xx
2006 let x$="*"
2008 print at 10,0; bright 1;z$( to row );x$;z$( row+1 to )
2010 let k=code inkey$ : if k then beep .02,0 : end if
2011 if k>31 and k<128 then goto 2264 : end if
2012 if k=13 then end :end if
2018 let row=0 : goto 2008
2020 goto 2004
2022 poke 23658,8 and not peek 23658 : goto 2006
2024 let z$="" : let row=0 : goto 2008
2026 if not row then goto 2010 : end if
2027 let row=row-1 : goto 2008
2028 if row=length then goto 2010 :end if
2029 let row=row+1 : goto 2008
2030 if row+32>length then goto 2010 :end if
2031 let row=row+32 : goto 2008
2032 if row<32 then goto 2010 : end if
2033 let row=row-32 : goto 2008
2034 if not row then goto 2010 : end if
2035 let row=row-1 : goto 2041
2036 print at 10,0;z$;">" : return
2038 goto 2010
2040 if row=length then goto 2010 : end if
2041 let z$( row+1 to )=z$( row+2 to ) : let z$(length)="" : goto 2008
2264 if row=150 then goto 2010 : end if
2265 let row=row+1 : if row<length then let z$( row+1 to )=z$( row to ):end if
2266 print k:let z$(row)=chr$(k) : goto 2008
2499 goto 2010
I'm always on the chat or facebook.
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Sat Feb 21, 2015 12:53 pm

Re: Using inkey

So much fun on this one. No matter what I do it almost works, but not quite works.
I'm always on the chat or facebook.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Sat Feb 21, 2015 5:42 pm

Re: Using inkey

ardentcrest wrote:HUMMMMM. Posts when missing :(

Need help. This compiles with no errors but still will not work. Any help.

  Code:
2022 poke 23658,8 and not peek 23658 : goto 2006


Looking to line 2022. What are you trying to do here?
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Sat Feb 21, 2015 9:23 pm

Re: Using inkey

I believe that just flashes the cursor when a key is pressed.
I'm always on the chat or facebook.
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Sat Feb 21, 2015 10:58 pm

Re: Using inkey

ardentcrest wrote:I believe that just flashes the cursor when a key is pressed.


:D :D :D Got it working......

  Code:
10 dim z$ : let z$="this is a test of an inkey$ editor                 " : gosub 2000 :stop
2000 rem INPUT+
2002 let length=len z$
2004 let row=32
2006 let x$="*"
2008 print at 10,0; bright 1;z$( to row );x$;z$( row+1 to )
2010 let k=code inkey$ : if k then beep .2,0 : end if
2011 if k>31 and k<128 then goto 2264 : end if
2012 if k=13 then goto 2036  :end if
2013 if k=8 then goto 2026  :end if
2014 if k=9 then goto 2028  :end if
2015 if k=10 then goto 2030  :end if
2016 if k=11 then goto 2032  :end if
2017 if k=12 then goto 2034  :end if
2018 if k=7 then goto 2024  :end if
2019 goto 2010


2026 if not row then goto 2010 : end if
2027 let row=row-1 : goto 2008
2028 if row=length then goto 2010 :end if
2029 let row=row+1 : goto 2008
2030 if row+32>length then goto 2010 :end if
2031 let row=row+32 : goto 2008
2032 if row<32 then goto 2010 : end if
2033 let row=row-32 : goto 2008
2034 if not row then goto 2010 : end if
2035 let row=row-1 : goto 2041
2036 print at 10,0;z$;">" : return
2038 goto 2010
2040 if row=length then goto 2010 : end if
2041 let z$( row+1 to )=z$( row+2 to ) : let z$(length)="" : goto 2008
2264 if row=150 then goto 2010 : end if
2265 let row=row+1 : if row<length then let z$( row+1 to )=z$( row to ) : end if
2266 let z$(row)=chr$(k) : goto 2008
2499 goto 2010


Silly me had a let row=0 in line 2018, just had to remove it :oops:

Just need now to work out how to get it to print in 42 or 64. And on the bottom two lines.

Still a bit buggy need to work on how ROW works.
I'm always on the chat or facebook.
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Mon Feb 23, 2015 12:00 pm

Re: Using inkey

Sorry Sorry sorry......

  Code:
INK 7 : PAPER 0 : BORDER 0 : CLS

#include <keys.bas>

let length=60 : let rowx=0 : let xx$="<"

NETinputloop:

   if rowx=0 then print at 22,0;xx$ : goto NetJump1 : end if
   print at 22,0; : FOR ii = 0 TO rowx : print chr$(peek (@MyLabel + ii)); : NEXT ii : print xx$;"  "

NetJump1:
   let k=code inkey$ : if k then beep .2,0 : end if
   if k>31 and k<128 then goto NetKeyPress : end if
   if k=13 then end : end if
   if k=12 then goto NetDeleteKey : end if
   goto NetJump1

NetDeleteKey:
   if rowx=0 then goto NETinputloop : end if
   POKE (@MyLabel + rowx), 0
   let rowx=rowx-1
   goto NETinputloop

NetKeyPress:
   if rowx=length then goto NETinputloop : end if
   POKE (@MyLabel + rowx), k
   let rowx=rowx+1
   goto NETinputloop


    MyLabel:
    ASM
    text1:
    ds 1024  ;  1024 bytes of space MAX!!
    END ASM


    MyLabel2:
    ASM
    lenth1:
    ds 1  ;  1024 bytes of space MAX!!
    END ASM


When NetDeleteKey: it should move the cursor back but does not. What am I missing.
I'm always on the chat or facebook.
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Mon Feb 23, 2015 12:24 pm

Re: Using inkey

OK.............

GOT IT :D

POKE (@MyLabel + rowx), 0 should be POKE (@MyLabel + (rowx-1)), 0

2 hours looking at that one.....
I'm always on the chat or facebook.

Return to Help & Support

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO