2 text questions

Non-platform specific questions.

2 text questions

Postby Kalladdolf » Thu Jul 31, 2008 7:43 pm

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.
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: 2 text questions

Postby feral » Thu Jul 31, 2008 11:43 pm

==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.
Last edited by feral on Wed Aug 06, 2008 4:45 am, edited 2 times in total.
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: 2 text questions

Postby Kalladdolf » Fri Aug 01, 2008 5:32 am

feral wrote:try \n in the string for newline.

thanks!

ok, any1 for number 2?
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: 2 text questions

Postby Kalladdolf » Mon Aug 04, 2008 4:44 pm

ANYONE?

Please, I need this desperately, othewise... *splat*
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: 2 text questions

Postby feral » Mon Aug 04, 2008 11:41 pm

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 ?
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: 2 text questions

Postby Kalladdolf » Tue Aug 05, 2008 7:35 am

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

that's exactly it.
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: 2 text questions

Postby feral » Wed Aug 06, 2008 4:42 am

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..
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: 2 text questions

Postby Fuzzy » Wed Aug 06, 2008 7:26 am

You dont need to check the length. Just do it every draw. You also should not need to empty the text.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: 2 text questions

Postby feral » Wed Aug 06, 2008 7:49 am

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 ?
Last edited by feral on Wed Aug 06, 2008 11:36 pm, edited 1 time in total.
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: 2 text questions

Postby Kalladdolf » Wed Aug 06, 2008 8:33 am

thanks, you know about more codes than i do XD
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron