Finding a certain number/letter at position "x"

Get help using Construct 2

Post » Wed Jan 16, 2013 3:59 pm

Here is the problem:
I got a text box with 5numbers, how could I for example see the 4th number in this piece of text?

Example:
Text = 57396
Find the 2nd number
I should get the answer 7

I tried mid function, might not be doing it correctly?

If anyone got an idea on how to do this and would like to add a capx I would be grateful!
(\__/)
(='.'=)
(")_(")
B
20
S
9
G
1
Posts: 68
Reputation: 3,057

Post » Wed Jan 16, 2013 4:21 pm

'Left' function :)
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Post » Wed Jan 16, 2013 4:35 pm

Could you provide some kind of capx()? Might be setting it up wrong.
(\__/)
(='.'=)
(")_(")
B
20
S
9
G
1
Posts: 68
Reputation: 3,057

Post » Wed Jan 16, 2013 8:10 pm

Use mid(), the position is zero based so to get the first digit use:
mid(Text.Text, 0, 1)
second:
mid(Text.Text, 1, 1)
third:
mid(Text.Text, 2, 1)
...
B
79
S
24
G
54
Posts: 4,749
Reputation: 40,761

Post » Wed Jan 16, 2013 8:58 pm

https://www.scirra.com/manual/126/system-expressions

Some fantastic tools in here. It's always worth reviewing what toolset has to offer. You never know what you will be inspired to create or refine by going through it once and a while.
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests