Page 1 of 1

Putting variable data together

PostPosted: Mon May 28, 2007 3:14 pm
by Troodon
Hi,
Sorry to disturb you with my endless variable problems, but is there a way to put variables in a row in a textNumber?

I've tried things like
textNumber = firstvariable & secondvariable & thirdvariable

PostPosted: Mon May 28, 2007 4:50 pm
by makslane
What exactly you want to show?

PostPosted: Mon May 28, 2007 5:56 pm
by Troodon
I want to display variables like this:

An text actor's value:
2075682

when
Variable1: 20
Variable2: 75
Variable3: 682

So the variable 1-3 values are put one after one.
(Like in VB script when you add a text between two variables
lbl_info.text = myvariable & " times in" & 2ndvariable & " days")

PostPosted: Mon May 28, 2007 8:41 pm
by makslane
Use the sprintf function. If the Variable1, Variable2 and Variable3 are integers, use:

Code: Select all
sprintf(text, "%d%d%d", Variable1, Variable2, Variable3);

strings

PostPosted: Tue May 29, 2007 8:51 am
by kyensoftware
What if they are strings??

PostPosted: Tue May 29, 2007 11:52 am
by Jarzynek
Try %s instead of %d

PostPosted: Tue May 29, 2007 4:31 pm
by Sgt. Sparky
and a float/real is %f. :D

PostPosted: Tue May 29, 2007 6:28 pm
by Troodon
WOW! This simple code is extremely handy!!!

PS: Am I the only one who doesn't know C language beside GE's ennobled C?

PostPosted: Tue May 29, 2007 6:31 pm
by Sgt. Sparky
nope,
I know alot of C,
but I have problems programming outside of GE because I do not have the right softwhere. :(