Page 1 of 1

2 text questions

PostPosted: Thu Jul 31, 2008 7:43 pm
by Kalladdolf
Number one:
Is there a way to determine the font or the lines in a text when you use the strcpy() function?

Number two:
I forgot how to limit the maximum char number of a textbox.

Thanks.

Re: 2 text questions

PostPosted: Thu Jul 31, 2008 11:43 pm
by feral
==Kalladdolf== wrote:Number one:
Is there a way to determine the font or the lines in a text when you use the strcpy() function?


I don't think you can change the font in the same textbox, you would need to swap different textboxes with different fonts "in an out" using a routine..I am also pretty sure you can't MIX fonts.

that said, if you really need to, you could create a image file of a font containing different fonts and use that.. ie: the uppercase letters in your image file might be "uppercase arial" but the lower case letters might be "uppercase times new roman."

next, if by lines, you mean linebreaks... try inserting the characters \n in the string for newline.

eg: strcpy(text," hi !\nhow are you ?\nmore text\nmore text ");
would result in
hi !
how are you ?
more text
more text

i am not sure of the third question, sorry,.. someone else may need to answer that.

Re: 2 text questions

PostPosted: Fri Aug 01, 2008 5:32 am
by Kalladdolf
feral wrote:try \n in the string for newline.

thanks!

ok, any1 for number 2?

Re: 2 text questions

PostPosted: Mon Aug 04, 2008 4:44 pm
by Kalladdolf
ANYONE?

Please, I need this desperately, othewise... *splat*

Re: 2 text questions

PostPosted: Mon Aug 04, 2008 11:41 pm
by feral
Kalladdolf

I found this post
viewtopic.php?f=4&t=2990&p=15919&hilit=limit+textbox#p15919

It appears there is no built in way to limit the text boxchars.

that said, if you want to explain exactly what you want i should be able to code something that will help..

I assume you want to STOP the amount of text that can be input ?

Re: 2 text questions

PostPosted: Tue Aug 05, 2008 7:35 am
by Kalladdolf
feral wrote:I assume you want to STOP the amount of text that can be input ?

that's exactly it.

Re: 2 text questions

PostPosted: Wed Aug 06, 2008 4:42 am
by feral
OK, this may not do exactly what you want, so let me know if it doesn't , as, this was just a very first rough stab at the problem..I will probably fine tune it later.. but test it out and let me know what it needs

( or if anyone else wants to help clean it up ,... my string handling is my weakest code)

basically it uses a temporary holding string, and every time your input string gets to big, it copies upto the max characters to the holding string... then deletes all input and copies back the original limited amount of chars

TO USE:
1. create a text actor for input
2. and a second off screen one to hold the temp string ( you can also use the text attribute of any character, or create a global holding string variable, but this way you get to see what happens if you leave the temp textactor on screen)

in this case the second temp textactor is called text2 ( could be anything)

3. then in the "draw" code of your input text box, copy the following code..

also see notes below..

Code: Select all

if (strlen(text)>20) // if string length is greater then max lenght (not incluiding null characters)
{
     strncpy(text2.text,text,20);
             // string N copy (strncpy) max amount to temp holding string
             // in this case another text actor - could easily be an ordinary string.
             // strncpy copies upto the number of characters specified
             // see ge script reference
                   
 
     strcpy(text,"");
            // empty the curent textbox (all characters inlcuding extras)
            // by copying empty string.
 
     strcpy(text,text2.text);
            // copy temp holding string back into textbox

     strcat(text," ");
            // add a space at the end of text box
            // note: this is a GE thing - otherwise the textbox closes in
            // (ie: only needed to stop textbox becoming smaller then string)
 
}



NOTES: Currently, if the max input limit is reached, the text-input box automatically loses focus ( which could be a good thing... as it stops you from typing more).. you have to then, click back in the box to continue ( where you can delete, backspace overwrite etc), but if you add another character to the end (or insert a character) the whole routine is triggered again..

Re: 2 text questions

PostPosted: Wed Aug 06, 2008 7:26 am
by Fuzzy
You dont need to check the length. Just do it every draw. You also should not need to empty the text.

Re: 2 text questions

PostPosted: Wed Aug 06, 2008 7:49 am
by feral
Fuzzy wrote:You dont need to check the length. Just do it every draw. You also should not need to empty the text.


sounds good fuzzy?

sorry, as i said, my string handling skills are woeful...

fuzzy ...could you code an example of your version for us ?

Re: 2 text questions

PostPosted: Wed Aug 06, 2008 8:33 am
by Kalladdolf
thanks, you know about more codes than i do XD