How do I parse strings?

Get help using Construct 2

Post » Thu Dec 10, 2015 11:15 pm

Hi guys,

I googled for a while, and read the expressions documentation, but I cant find the way how to parse strings.
I want to take string data (number) entered in text box from it and use as a value for global variable. So I can write number in the texbox while runnig the app and use that value in some calculations.

How can I do that? Thx in advance.
Try my creations on newgrounds or Google play, feedback highly appreciated!

ImageImage
B
9
S
1
Posts: 73
Reputation: 785

Post » Fri Dec 11, 2015 4:21 am

Hi,
I'm confused, I need more info. Are you expecting different numbers in your textbox input and therefore trying to separate (parse) them into individual number data? Or are you trying to use a number typed into a textbox as a global value. If it is the latter I would do this:

TextBox: On text changed > System: set "GlobalVariable" to int(trim(TextBox.text))

int() changes a string into an interger and trim() makes sure you didn't accidentally hit the space bar. You can also change to condition to when button clicked if you want to wait for the full number to be typed in.

If this has not answered your question, please give an example of what you are trying to do.
B
16
S
9
G
5
Posts: 74
Reputation: 4,120

Post » Fri Dec 11, 2015 11:08 am

Yes that is what I was looking for. I did not know how to ask the question.

Solution worked perfectly, thank you :)
Try my creations on newgrounds or Google play, feedback highly appreciated!

ImageImage
B
9
S
1
Posts: 73
Reputation: 785


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests