Having problems adding extra data on a label, without clearing original text

Started by mrsix, Thu 16/10/2008 08:23:26

Previous topic - Next topic

mrsix

Sorry if i'm being a bit silly!
But i'm having a problem with a label.

I have some buttons, when I press button 1, I want it to add a "1" to the label. When I press it again, I want it to add another "1", so I would get "11"
If i pressed button one 4 times it would say "1111" in the label.

I can make it so that pressing button one sets the label to 1, but thats it. Im guessing that because it is text rather than numericals, I have to stop it from calculating, but rather ADDING the text next to it.
I thought using a code something like

function Button1_OnClick(GUIControl *control, MouseButton button)
{
Label.Text = Label.Text +("1");
}

So that it basically says keep the label as it is, but add a 1 next to what it currently contains. Obviously the above code does not work, but you can see what I mean. Does anybody know how to solve this simple problem, or even if it is possible with a label? Sorry, I have searched all evening yesterday on the manual and could not find an example i'm afraid.

Gilbert


monkey0506

The proper function is String.Append. You could alternately in this case use String.AppendChar using the ASCII character '1' (note the single-quotes for a char, not "1" which is a string).


SMF spam blocked by CleanTalk