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.

Code Snippets / DEXTER - Dynamic Text Editor (Input / Store Strings)

Author
Message
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 11th Mar 2006 18:02 Edited at: 15th Mar 2006 15:19
I've seen a few posts asking how to accomplish entering text whithout using the INPUT command as it messes up the syncronization of the program, so I've been working on this function. I was concidering creating a library of functions but 1 function should do the job.

The only current working feature is the input of single-line text wherever you want on the screen, but I thought I'd share it as it still works. I know / was working on adding in these features this morning:

- Text Wrapping (So no cut-off words at the end of lines)
- Multi-Line Text Input
- On/Off Setting (So say you wanted to only allow them to input text when they clicked a button)
- Some other things I cant remember right now

Anyways I have to go to a friend's birthday today so I wont have much time to work on the function and tomorrow Im off to a wedding. Ill try and finish off the function tonight but if not tomorrow afternoon should be enough time unless something comes up.

Either way, here's the basic function without the features I mentioned above:



As of right now the while loop stops the program for a second when the backspace is pressed but its just temporary, like I said this is just a basic skeleton of the system but I thought I'd get it out there.

Here's what each parameter currently does:

String$ : The String variable name to store the input data in.
Backspace : The keystate for the backspace button, added this param incase people didnt want to use the backspace key (which is keystate 14 if you're wondering)
Delay# : The Delay# between backspaces, use this with the next param to get the desired result
Rate# The rate of decrease that Delay# goes by. So if Delay# was 5000 and Rate# was 1, it would loop 5000 times decreasing Delay# by 1.

And a sample of using the function:



Move with the arrow keys / type your message with... all... of the keys And use backspace to delete.

As you'll see the backspace halts the program because of the size of the loop, not to worry Ill fix that when I release the full version.

Last note; The function returns the string to be displayed. Looking at the code you'll notice that in the sample you pass the string returned as the string name, this prevents you from having to declare string as a global.

- RUC'

Turoid
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 14th Mar 2006 16:31
Perfect function !


.::Studying game design at the moment::.
Digital Dragon
19
Years of Service
User Offline
Joined: 17th Dec 2004
Location: ...
Posted: 25th Apr 2006 21:49
Good but little problem when you use backspace too many times

musty
18
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Istanbul
Posted: 26th Apr 2006 19:23 Edited at: 26th Apr 2006 19:37
That is exactly the same code I used for my text adventure. Well almost exactly. Your code is much tidier, more efficient etc. etc. But the logic is the same. (Of course I blocked the keys other than the standard alphanumeric ones,removed multiple spaces and converted the text to uppercase to simplify the parsing)
I used to write an alternative input routine for my commodore 64 text adventure game. Your thread reminded me of those old days. Thank you.

"Ignorance is bliss." Cypher from the movie The Matrix
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Apr 2006 12:07
I dont know wtf is wrong with darkbasic, but I get weird problems with keystate.

Technically, this should do the same thing. I'll get nonsense characters and eventually the text disappears altogether and it'll no longer give me any strings. The rest of the program continues to run just fine.




Login to post a reply

Server time is: 2024-11-23 07:36:17
Your offset time is: 2024-11-23 07:36:17