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.

Dark GDK / Text imput

Author
Message
bobba
16
Years of Service
User Offline
Joined: 10th Apr 2008
Location:
Posted: 23rd Apr 2008 00:19
Greetings,

I need help.

Could someone please explain how to use the dbEntry()or other function to imput a string of text from the keyboard and store it as a string or char buffer[x];

i can get the folowing code to compile but canot convert the *char to a string or char array for futher use.

dbClearEntryBuffer ();
int lok =1;
while (lok==1)

{
if (dbKeyState ( 28 )==1 ) // enter is pressed
{
lok=4;//Exit loop
}

}

char *bufbuffer[30];
*bufbuffer = dbEntry();

I dont understand why it has a $ sign in the help file yet it wont work if it is used.

thanks in advanse for any help.


Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 23rd Apr 2008 00:28 Edited at: 23rd Apr 2008 00:28
The $ sign is probably left over from the Dark Basic documentation and wasn't stripped off. If I remember what little Basic I used it typically indicates a string type variable.

I'm not going to sort through your code or try to get it to work since I'm on the clock for something else right now. But I will point out that

char *bufbuffer[30];

doesn't declare a buffer of 30 characters. It declares a buffer of 30 character pointers. Try changing that segment of your code to

char bufbuffer[30];
bufbuffer = dbEntry();

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
bobba
16
Years of Service
User Offline
Joined: 10th Apr 2008
Location:
Posted: 23rd Apr 2008 03:27
thanks for the sugestion, unfortunatly it did not work but I worked it out, hear is the code for anyone else who is stuck.

dbClearEntryBuffer (); // this clears the whindows buffer

int lok =1;
while (lok==1) // this waites in a loop untill enter is pressed
{

dbText( ((ScreenX/2)-200), ((ScreenY/2)-200),
"please enter text" ) ;


if (dbKeyState ( 28 )==1 ) // key state 1 == enter
{
lok=4;//Exit
}
dbSync ( );
}




char text[30]="";;
sprintf(text,"%s",dbEntry () ); // this one gets the buffer
dbText( ((ScreenX/2)-200), ((ScreenY/2)-200),text ) ;
Ghthor
16
Years of Service
User Offline
Joined: 5th Apr 2008
Location:
Posted: 24th Apr 2008 01:11 Edited at: 24th Apr 2008 01:20
Heres the Class I made for User input as the dbEntry() command was a lackluster way to gather userinput



why does it keep changing '\0' sequences to '?' in the code snippet?

You have to write the code to Handle Enter key and so forth, but you can just have it so if enter is pressed you copy the string out of this class to where ever you want it and clear the UserInput sring for use again somewhere else.

Taco Justice
bobba
16
Years of Service
User Offline
Joined: 10th Apr 2008
Location:
Posted: 2nd May 2008 06:51
// tis version is better, less cals to sync


dbClearEntryBuffer (); // this clears the whindows buffer

int lok =1;
dbText( ((ScreenX/2)-200), ((ScreenY/2)-200),
"please enter text" ) ;

dbSync ( );

while (lok==1) // this waites in a loop untill enter is pressed
{

if (dbKeyState ( 28 )==1 ) // key state 28 == enter
{
lok=2;//Exit
}

}

dbSync ( );

char text[30]="";;
sprintf(text,"%s",dbEntry () ); // this one gets the buffer
dbText( ((ScreenX/2)-200), ((ScreenY/2)-200),text ) ;
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd May 2008 16:50
bobba, please use the edit button and put your code in tags that look like this:

[ code ]
Code Here.
[ / code ]

(But without the spaces in the tags so you get...

)

That said... I personally like the roll your own dbInput Wrappers you guys are doing and I personally am going to roll my own... I'm almost at the point where I'm ready to.

Login to post a reply

Server time is: 2024-11-20 09:26:05
Your offset time is: 2024-11-20 09:26:05