Is there a 'tokenfind' type of function?

Discussion and feedback on Construct 2

Post » Mon Jul 07, 2014 5:03 pm

I use tokenat and tokencount, which are great for working with lists of data w/ delimiters.

Is there an equivalent function to find the index of a value within a list?

For example, something like tokenfind("apples|oranges|bananas", "oranges", "|") would return the value 1.

Many thanks.
B
11
S
2
Posts: 86
Reputation: 1,001

Post » Mon Jul 07, 2014 7:10 pm

There is no dedicated expression, but if you loop through the tokens within the string, comparing each token to the desired value, the loopindex will be the index of the matching token. If you'll be using this same process in multiple areas of your project, it would make sense to create your own function for finding a token's index.
B
62
S
19
G
8
Posts: 341
Reputation: 12,075


Return to Construct 2 General

Who is online

Users browsing this forum: Cliffu and 1 guest