Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: QuixoticNeutral on Fri 10/04/2015 22:02:16

Title: Unable to get the contents of a texbox
Post by: QuixoticNeutral on Fri 10/04/2015 22:02:16
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) Select

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. :/
Title: Re: Unable to get the contents of a texbox
Post by: Crimson Wizard on Fri 10/04/2015 22:09:57
When you format the string, you should use "%s", not "%d":

Code (ags) Select
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) Select

function tInput_OnActivate(GUIControl *control)
{
  Display("Text is: %d", tInput.Text);
}
Title: Re: Unable to get the contents of a texbox
Post by: QuixoticNeutral on Fri 10/04/2015 22:22:44
Yes, that fixed it! Thanks for the fast response. :)