Page 1 of 1

Format Control Strings in GE textNumber function??

PostPosted: Wed Jun 07, 2006 5:14 pm
by Just4Fun
I am not sure if this is the correct place to post this question. It isn't very advanced, but it is 'C' related. Here goes:

------------> 1. I have two actors: num1 & num2.
------------> 2. Each actor generates a random number between 1 and 100.

------------> Problem: I would like to have the numbers display using right justification.

So... the console display for the two actors would look something ike this:

-------------->33
------------> 100

As it stands now, I get a left justification (GE default?)

------------> 33
------------> 100

This is such a simple thing to do in 'C' with printf. Any ideas? Can this be accomplished in GE?

Image

PostPosted: Wed Jun 07, 2006 9:23 pm
by makslane
Just use the sprintf function. If you want display the variable count, try this:

Code: Select all
sprintf(text, "%5d", count);


The result will be:
Code: Select all
    1
   10
  100
 1000
10000

PostPosted: Wed Jun 07, 2006 9:52 pm
by Just4Fun
100,000 thanks Makslane.

It worked! Image