word in a text

Get help using Construct 2

Post » Sun Sep 10, 2017 8:29 pm

Hi,

i would like to know how to test if a word is in a text.

i try with "find", but the result is curious. 0 ? -1 ?

an help?
B
10
S
3
Posts: 81
Reputation: 828

Post » Mon Sep 11, 2017 5:07 am

"Find" returns position (starting from 0) of the search string, or -1 if string not found.
Find("abcdefgh", "ab") returns 0
Find("abcdefgh", "cd") returns 2
Find("abcdefgh", "xyz") returns -1
Check out my awesome game Doptrix
B
17
S
9
G
10
Posts: 223
Reputation: 6,987

Post » Mon Sep 11, 2017 5:29 am

Thank's !

so if find return is différent to -1, my word exist in the text !
B
10
S
3
Posts: 81
Reputation: 828

Post » Mon Sep 11, 2017 12:16 pm

Exactly.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
16
S
4
G
1
Posts: 428
Reputation: 2,337

Post » Mon Sep 11, 2017 8:50 pm

ok
B
10
S
3
Posts: 81
Reputation: 828


Return to How do I....?

Who is online

Users browsing this forum: zenox98 and 67 guests