Empty Strings that will fill with inkey.

Posted By: Rasch

Empty Strings that will fill with inkey. - 04/16/10 10:03

Hi there,

i got a problem. Maybe it is extrem easy and i just dont get it or it is more complicated.

At the moment i´m creating a login system. It is very simple and just .txt layered.

The first thing i do is create my Strings.

Code:
STRING* id_input = "#10";
STRING* pw_input = "#10";



The i have my input field with inkey function, a login and a register button.

Now what i want is. If player press the register button it should check if mininum 3 characters are typed in. That does not work because my strings are already 10 characters longs even if they dont have any characters in it.

This depends on the "#10" after string creation. So everytime i click register it checks the inputs and says: "yes theres is more than 3 characters." But there isnt. laugh

This is the check code.

Code:
input_check = str_len(id_input);

if(input_check > 2)
{
	// Write ID Data
}
else
{
	error("ID need at least 3 characters.");
}



If i create my strings with this one: ""

I just have one character to type in with inkey.

Now how can i manage it that my strings are all 1 character long as long as there is no inkey input?
Posted By: Henning

Re: Empty Strings that will fill with inkey. - 04/16/10 10:13

Hi,
at the remarks of the inkey function is this:
The str_cursor function can be used to get the current cursor position while the string is edited.
That should be useful to find the latest cursor position. If more than 2 then O.K. (count starts at 1)
Posted By: Rasch

Re: Empty Strings that will fill with inkey. - 04/16/10 10:18

Wow what a simple solution didnt see that function yet. It works well. Thank you laugh
Posted By: Lukas

Re: Empty Strings that will fill with inkey. - 04/16/10 13:42

But what if the user types in nothing but just moves the cursor three letters to the right? Or what if he types in more than 3 letters, but has to correct the first one, so the cursor end up at the left end? wink

I rather suggest to check if there is a non-space character at the third letter or later.
© 2024 lite-C Forums