Unable to get the contents of a texbox

Started by QuixoticNeutral, Fri 10/04/2015 22:02:16

Previous topic - Next topic

QuixoticNeutral

Hi all, I'm trying to assign the contents of a textbox into a variable, however for some reason I just can't seem to get it to work. :( The variable will always return null/0. The code looks like it should work as far as I can see:

Code: ags

function tInput_OnActivate(GUIControl *control)
{
  String userInput;
  userInput = tInput.Text;
  Display("Text is: %d", userInput);
}


I feel like the solution is probably really obvious, but I just can't figure it out. :/

Crimson Wizard

When you format the string, you should use "%s", not "%d":

Code: ags
Display("Text is: %s", userInput);


Also, as a tip, you do not need extra variable in the example you posted, you can just do:
Code: ags

function tInput_OnActivate(GUIControl *control)
{
  Display("Text is: %d", tInput.Text);
}

QuixoticNeutral

Yes, that fixed it! Thanks for the fast response. :)

SMF spam blocked by CleanTalk