Page 1 of 1

how to store text or string in a textbox?

PostPosted: Thu Nov 10, 2011 12:00 pm
by kengin
hi everyone im new here i hope you help me guys
how to store a text or string and can be show after calling it
example i want to stored this string "Hello World" and i want to show it after i click a actor

sorry if im not good in english ^_^

Re: how to store text or string in a textbox?

PostPosted: Thu Nov 10, 2011 1:09 pm
by skydereign
Well, storing it I assume you mean in a variable. You can add this code to a text actor to do just that.
Code: Select all
char string[] = "Hello World";
sprintf(text, "%s", string);

Of course the variable string is local to the event, so if you wanted it to be stored longer, you'd have to declare it in global code. And just to clarify, you can display text using the variable text. By setting it to something, if the actor has a font attached to it, then it will display it.

Re: how to store text or string in a textbox?

PostPosted: Thu Nov 10, 2011 2:14 pm
by kengin
i mean the string "hello world" in a textbox that you type will pass on the other actor after pressing a command actor

Re: how to store text or string in a textbox?

PostPosted: Thu Nov 10, 2011 2:23 pm
by foleyjo
Try strcpy . This will copy one string to another.

So if you have 2 actors 1 being actor and the other being the text box you can try

strcpy(actor.text, textbox.text);

Re: how to store text or string in a textbox?

PostPosted: Thu Nov 10, 2011 2:54 pm
by kengin
oh thank you but how i can pass the value of it on a user variable?

Re: how to store text or string in a textbox?

PostPosted: Thu Nov 10, 2011 8:50 pm
by foleyjo
same way. Just change text to the variable name

strcpy stands for string copy.

strcpy(actor.string, textbox.text);

Re: how to store text or string in a textbox?

PostPosted: Thu Nov 10, 2011 9:00 pm
by kengin
theres an error:
Illegal structure operation.
suspicious pointer conversion.

here is the code when i click a actor
strcpy(tempName.string,txtName.text);
the tempName is a user variable

Re: how to store text or string in a textbox?

PostPosted: Thu Nov 10, 2011 10:02 pm
by lcl
Write only:
Code: Select all
strcpy(tempName, txtName.text);

:D

Re: how to store text or string in a textbox?

PostPosted: Thu Nov 10, 2011 10:08 pm
by foleyjo
Yeah sorry about that.

In my example actor was the actor you wanted to copy the string to and string was the name of the string.

Re: how to store text or string in a textbox?

PostPosted: Fri Nov 11, 2011 2:37 am
by kengin
lcl wrote:Write only:
Code: Select all
strcpy(tempName, txtName.text);

:D


also error: suspicious pointer conversion
T_T

Re: how to store text or string in a textbox?

PostPosted: Fri Nov 11, 2011 9:17 am
by kengin
already solved XD thank you for the help guys.