Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Arjunaz78 on Mon 19/12/2011 03:17:57

Title: [SOLVE] About Using Text Box & GUIs Button
Post by: Arjunaz78 on Mon 19/12/2011 03:17:57
I've search the thread about using textbox..

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=35336.0

The only problem is,i cannot use a word or should i said alphabet that more than one lwhen using Append & Appendchar..

However i can use it if i use a single alphabet such as number ('1') or ('O') or ('u') & ('t')

I use the code as shown below..

function ButtonD1_OnClick(GUIControl *control, MouseButton button)
{
ButtonD1.Animate(10, 0, 15, eOnce);
 TBDrawing.Text = TBDrawing.Text.Append('Out')
}


and try to use like this..

function ButtonD1_OnClick(GUIControl *control, MouseButton button)
{
ButtonD1.Animate(10, 0, 15, eOnce);
 TBDrawing.Text = TBDrawing.Text.AppendChar('Out')
}


but the both of codes doesn't work at all..then i get..

GlobalScript.asc(749): Error (line 749): incorrectly terminated character constant


below is the graphic of that GUIs that i use..

http://imgur.com/6gwCU

Did i miss something or make a wrong way? or i can't use it together with .Animate code?

For your information,  'ButtonD1' is a custom GUIs Button at top right position of the picture and TBDrawing is a custom GUIs TextBox and i use the text parser too for that GUI's but the ('Out') word is not the one in text parser lib.
And i don't use Label GUIs instead of Button GUIs.
Title: Re: About Using Text Box & GUIs Button
Post by: Khris on Mon 19/12/2011 03:40:03
Looking at the manual entry for String.Append, the example is in there three(!) times: mytext.Append("World");

Note the double quotes: "

  TBDrawing.Text = TBDrawing.Text.Append("Out");
Title: Re: About Using Text Box & GUIs Button
Post by: Arjunaz78 on Tue 20/12/2011 01:04:19
Owh..thanks again khris..i didn't notice the different of both codes,it seems the same code style that make me confused, but now i got it..thanks again..  :)
Title: Re: [SOLVE] About Using Text Box & GUIs Button
Post by: Wyz on Tue 20/12/2011 02:14:58
The difference is that single quotes indicate a single character, and double quotes indicate a character sequence.
They are very different things in the realm of computers so that's why the programming language also makes the distinction. Some don't and allow both quotation styles to be used intermixed so I understand how that can be confusing for some.

If you type 'Out' AGS is expecting a single character, yet you gave three, so it will pick the first one. However that is not what you want, so use "Out" as Khris already pointed out.