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: 82
Reputation: 830

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
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
71
Posts: 1,069
Reputation: 38,701

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: 82
Reputation: 830

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
21
S
6
G
3
Posts: 664
Reputation: 3,855

Post » Mon Sep 11, 2017 8:50 pm

ok
B
10
S
3
Posts: 82
Reputation: 830


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 29 guests