Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / own input command: cant make it work

Author
Message
Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 12th Mar 2006 15:34 Edited at: 12th Mar 2006 18:09
Hi all.

Im trying to dreate my own input command. The only thing is that it doesent work.



It doesent print out the text at all , only the ">". But when i press the keybord keys nothing happens. And thats how far Ive come right now. Any help would be appriciated.
Coder#05
19
Years of Service
User Offline
Joined: 26th Oct 2005
Location: Denmark
Posted: 12th Mar 2006 18:19
you need to get your function to return the key being pressed...


also note that varialbes used in functions are not global..
meaning that you cant set string$ to be string$="your woord" and then get your function to print it out.
if so, you would need to create an array
DIM string$(1)
string$(1)="your woord"

hope that helped. and some one else plz correct me if im wrong.

Still a noob. easy comes easy goes
Chilled Programmer 420
19
Years of Service
User Offline
Joined: 24th Nov 2005
Location: NOT SAYING!, i dont wanna get kidnapped!
Posted: 12th Mar 2006 20:08
all u need is

global string$ as string

also it looks like ur code is erasing the word if no key is pressed, so if the user types summit then dosnt press anything, then string$ becomes""

try this...



[url=www.freewebs.com/tyhrfg][img]bruce.bmp[/img][/url]
Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 12th Mar 2006 20:27 Edited at: 12th Mar 2006 20:31
Thx, it worked . At last to one point. If you press a key, it will print out about twenty . And Ive tried two things to fix it, but none of them worked. Any ideas?



EDIT:

Ohhh, worked so much on this post I didnt notice 420 Chillaxed Programmer 420 post (I just wanted to check if I could fix the problem myself so no one could accuse me of letting the coding part to others!). I will check that out tomorrow (I dont have any more time today).
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 12th Mar 2006 21:00 Edited at: 12th Mar 2006 21:01
Stupid internet, made a double post

"Forgiveness is a good thing"
"Forgiveness is between them, and God. I set up the meeting"
-Man on Fire
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 12th Mar 2006 21:00
endfunction string and what Chillaxed said, should not repeat then.

"Forgiveness is a good thing"
"Forgiveness is between them, and God. I set up the meeting"
-Man on Fire
Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 13th Mar 2006 16:25
420 Chillaxed Programmer 420

The main reason I want to make an own input command is so I can have a input command that doesent pause the rest of the program. The code you propose does that.

And there is one more thing. I dont understand the "entry$()" command. Ive read the explanation in the help files, but dont understand it. Can anyone explain it for me?
Chilled Programmer 420
19
Years of Service
User Offline
Joined: 24th Nov 2005
Location: NOT SAYING!, i dont wanna get kidnapped!
Posted: 13th Mar 2006 16:52
ever had ur computer freeze whilst typing then all of a sudden, what u wrote apears on screen? that because the computer takes all the input and saves it, the entry command will read it, and the clear entry buffer command will erase it so u dont use the same bit twice

as for the not pausing... ill get back to u on that...

[url=www.freewebs.com/tyhrfg][img]bruce.bmp[/img][/url]
Chilled Programmer 420
19
Years of Service
User Offline
Joined: 24th Nov 2005
Location: NOT SAYING!, i dont wanna get kidnapped!
Posted: 13th Mar 2006 16:58 Edited at: 14th Mar 2006 13:52
use this in tour main loop, when the returnkey is pressed the input will be saved as word$
there is also a backspace option
you can paste text in
there is a flashin cursor
and the option of a message before the text

hope it helps.



the
Quote: "if output=1
output=0
cls
print word$
sync
wait 1000
endif"
bit is just there to show the returned word.

[url=www.freewebs.com/tyhrfg][img]bruce.bmp[/img][/url]
Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 13th Mar 2006 18:16
I think I got the entry part, at last. But I dont understand the " get clipboard$" command. Care to explain? Ill try this later on my function.
Mr Black
19
Years of Service
User Offline
Joined: 20th Oct 2005
Location: USA
Posted: 14th Mar 2006 00:48
I used that code and it is great, but one thing, what is the get clipboard$ command for, and why is it that everytime i go back to the area of my program i used this on, all the text i have previously entered is still there.
Chilled Programmer 420
19
Years of Service
User Offline
Joined: 24th Nov 2005
Location: NOT SAYING!, i dont wanna get kidnapped!
Posted: 14th Mar 2006 13:47
when you highlight text, and copy it, it goes to the clipboard, what that is doing is retrieving that when you press ctrl+v

and @ mr black, im not to sure what you mean...

[url=www.freewebs.com/tyhrfg][img]bruce.bmp[/img][/url]
Mr Black
19
Years of Service
User Offline
Joined: 20th Oct 2005
Location: USA
Posted: 14th Mar 2006 17:27 Edited at: 14th Mar 2006 17:33
Ok, i have a program that asks for a password using the your code snippet. It does what i want, but when i go back to that same screen later, everything i have previously typed in my program after entering the password is still there. Hope that helps.

Here is the code i am currently using(I know it is messy)



its probably not made in the most resourceful way.

edit: is there a way to replace the letters typed with *, since it is a password screen after all.
Chilled Programmer 420
19
Years of Service
User Offline
Joined: 24th Nov 2005
Location: NOT SAYING!, i dont wanna get kidnapped!
Posted: 14th Mar 2006 18:01
here ya are


it brings up what u had before because its stored in the entry buffer, simply use "clear entry buffer" before reusing it and you will be fine.

[url=www.freewebs.com/tyhrfg][img]bruce.bmp[/img][/url]
Mr Black
19
Years of Service
User Offline
Joined: 20th Oct 2005
Location: USA
Posted: 14th Mar 2006 21:56 Edited at: 14th Mar 2006 22:29
Ok, well that works pretty well, but now i cant get it to store what is typed seperate from the *. I want the computer to know the letters typed so it can see if the password is correct. I am working on it right now and i cant get it. I tried to store text$ as another string but then it doesn't type more then 1 *. Before the loop i put input$=text$ I will keep trying though.

Here is what i have so far thanks to (420 Chillaxed Programmer 420)
Mr Black
19
Years of Service
User Offline
Joined: 20th Oct 2005
Location: USA
Posted: 15th Mar 2006 01:58
YES, i got it, thanks for the help, couldn't have done it without you (420 Chillaxed Programmer 420) and some other people who helped my on the other forum.
Chilled Programmer 420
19
Years of Service
User Offline
Joined: 24th Nov 2005
Location: NOT SAYING!, i dont wanna get kidnapped!
Posted: 15th Mar 2006 11:49
happy to help m8y, what program you making anyway?

[url=www.freewebs.com/tyhrfg][img]bruce.bmp[/img][/url]
Mr Black
19
Years of Service
User Offline
Joined: 20th Oct 2005
Location: USA
Posted: 15th Mar 2006 12:31 Edited at: 15th Mar 2006 12:44
Well, its a simple program right now, it makes different profiles for my family by letting them fill out info and i am going to make a bunch of options like change background and stuff. 3d was too hard for me so i figure it would be best to start with this. Thanks for the help though, hopefully i can get the rest.
Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 15th Mar 2006 12:49 Edited at: 15th Mar 2006 12:52
Got most of it to work, but when I use backstab, it erases HUGE parts of the text. I didnt use the "wait" command, because I didnt want to stop the rest of the program. And I cant seem to get it to output the text then I press enter.

Here is the code:



EDIT:

Quote: "Well, its a simple program right now, it makes different profiles for my family by letting them fill out info and i am going to make a bunch of options like change background and stuff. 3d was too hard for me so i figure it would be best to start with this. Thanks for the help though, hopefully i can get the rest. "


Seems like a good project if you want to learn (lol, I didnt even think about anything like that), and it seems quite cool. Goodluck with it .
Chilled Programmer 420
19
Years of Service
User Offline
Joined: 24th Nov 2005
Location: NOT SAYING!, i dont wanna get kidnapped!
Posted: 15th Mar 2006 13:14
just make it so if backspace is pressed it will only delete one char, until it is depressed, then one more when it is pressed again.

[url=www.freewebs.com/tyhrfg][img]bruce.bmp[/img][/url]
Mr Black
19
Years of Service
User Offline
Joined: 20th Oct 2005
Location: USA
Posted: 15th Mar 2006 13:16 Edited at: 15th Mar 2006 13:28
Thank you

maybe this will work, its what i used to backspace.



dont forget the wait part(in this format it does not freeze the program, just try it, it has to be in the loop though, well it did in mine atleast)

Good luck with your project too.

420 Chillaxed Programmer 420 or someone else has to help u with the output thing. Its different then mine.
Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 15th Mar 2006 20:44 Edited at: 15th Mar 2006 20:44
Quote: "just make it so if backspace is pressed it will only delete one char, until it is depressed, then one more when it is pressed again.
"


Ok, Ive tryed it, but dont get it entierly right. It only erase one letter , then it stops. If you write a bit more, you can erase a letter again. This is the code:


The second line with commands in the entire program looks like this
, so kp is a global. Have I done that part right (its the first time Ive made a global without using arrays)?

Any ideas?

Quote: "dont forget the wait part(in this format it does not freeze the program, just try it, it has to be in the loop though, well it did in mine atleast)"


Sry, dont want to use the "wait" command at all. Even if its at an as low level as 50, it stops the program for about 50 miliseconds, and even though thats nothing, I still dont want to do it.

Quote: "Good luck with your project too. "


As you put it: Thank you.
Chilled Programmer 420
19
Years of Service
User Offline
Joined: 24th Nov 2005
Location: NOT SAYING!, i dont wanna get kidnapped!
Posted: 15th Mar 2006 20:49 Edited at: 15th Mar 2006 20:50
try...


your code was making kp=1 every time regardless

[url=www.freewebs.com/tyhrfg][img]bruce.bmp[/img][/url]
Mr Black
19
Years of Service
User Offline
Joined: 20th Oct 2005
Location: USA
Posted: 16th Mar 2006 00:42 Edited at: 16th Mar 2006 00:43
oops, sorry double post.
Mr Black
19
Years of Service
User Offline
Joined: 20th Oct 2005
Location: USA
Posted: 16th Mar 2006 00:42
Ok, well good luck with that, hopefully 420 Chillaxed Programmer 420 code works.
Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 16th Mar 2006 19:28 Edited at: 16th Mar 2006 19:36
It doesnt work (Ive learnd that
is the same as
, and it works).

Etire code:



EDIT:

I forgot to ask what the "left$" and the "len" commands do. Can anyone explain them (for some reason Ive hard to understand the explanations in the helpfiles)?
Chilled Programmer 420
19
Years of Service
User Offline
Joined: 24th Nov 2005
Location: NOT SAYING!, i dont wanna get kidnapped!
Posted: 16th Mar 2006 21:10
the len() command will return how many charecters are in the specified string and the left$() comand will return the x amount of left charecters, example... string$="testing" the function left$(string$,4) will return the 4 leftmost charecters,in this case "test".

and the differance i can see is that
will only wait if backspace(key 14) is pressed, but
will wait weather key 14 is pressed or not.

hope this helps

[url=www.freewebs.com/tyhrfg][img]bruce.bmp[/img][/url]
Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 18th Mar 2006 19:54 Edited at: 18th Mar 2006 19:55
Ok, I understand now.

But your wrong about
. And here is a code to prove it
. My guess it that when you write "if condition then blah" the condition applyes to the entire line, but not longer then that.

Login to post a reply

Server time is: 2024-11-27 23:37:03
Your offset time is: 2024-11-27 23:37:03