how to store text or string in a textbox?

Non-platform specific questions.

how to store text or string in a textbox?

Postby kengin » Thu Nov 10, 2011 12:00 pm

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 ^_^
User avatar
kengin
 
Posts: 11
Joined: Thu Nov 10, 2011 4:12 am
Score: 1 Give a positive score

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

Postby skydereign » Thu Nov 10, 2011 1:09 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

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

Postby kengin » Thu Nov 10, 2011 2:14 pm

i mean the string "hello world" in a textbox that you type will pass on the other actor after pressing a command actor
User avatar
kengin
 
Posts: 11
Joined: Thu Nov 10, 2011 4:12 am
Score: 1 Give a positive score

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

Postby foleyjo » Thu Nov 10, 2011 2:23 pm

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);
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score

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

Postby kengin » Thu Nov 10, 2011 2:54 pm

oh thank you but how i can pass the value of it on a user variable?
User avatar
kengin
 
Posts: 11
Joined: Thu Nov 10, 2011 4:12 am
Score: 1 Give a positive score

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

Postby foleyjo » Thu Nov 10, 2011 8:50 pm

same way. Just change text to the variable name

strcpy stands for string copy.

strcpy(actor.string, textbox.text);
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score

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

Postby kengin » Thu Nov 10, 2011 9:00 pm

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
User avatar
kengin
 
Posts: 11
Joined: Thu Nov 10, 2011 4:12 am
Score: 1 Give a positive score

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

Postby lcl » Thu Nov 10, 2011 10:02 pm

Write only:
Code: Select all
strcpy(tempName, txtName.text);

:D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

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

Postby foleyjo » Thu Nov 10, 2011 10:08 pm

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.
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score

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

Postby kengin » Fri Nov 11, 2011 2:37 am

lcl wrote:Write only:
Code: Select all
strcpy(tempName, txtName.text);

:D


also error: suspicious pointer conversion
T_T
User avatar
kengin
 
Posts: 11
Joined: Thu Nov 10, 2011 4:12 am
Score: 1 Give a positive score

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

Postby kengin » Fri Nov 11, 2011 9:17 am

already solved XD thank you for the help guys.
User avatar
kengin
 
Posts: 11
Joined: Thu Nov 10, 2011 4:12 am
Score: 1 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest