How do I recognize "newline" for "tokenat"?

Get help using Construct 2

Post » Sun Feb 22, 2015 2:26 pm

Hi. Since the XML Plugin does not seem to work right now (says XPath needs to be string instead of number, but I entered a string) I tried to use a comma separated list with values like:

a1, b1, c1
a2, b2, c2

I loaded the textfile with AJAX and tried the tokenat and tokencount system actions. I tried to use "newline" and "&newline" as separator and it returns a number for tokencount (1) but it does not seem to work. I make a For loop from 0 to tokencount and saved the result in a local variable. Then I used tokenat with "," as separator for the stored string to get the data for this entry (each line is one entry) but it returns both lines with the linebreak after c1. Any ideas how this might work?

Example code:
Image
Returned:
Stored Data: a1,b1,c1
a2,b2,c3
Stored Data:
B
51
S
15
G
5
Posts: 681
Reputation: 8,399

Post » Sun Feb 22, 2015 2:46 pm

Ah! I think I got it!
I used the string "newline" and not just newline as separator (was used to this from using "," and other chars). It returns 2 now and if I add -1 to the tokencountloop it seems to work fine. Or any other ideas to improve/change it?

Image

the loop:
Image
B
51
S
15
G
5
Posts: 681
Reputation: 8,399

Post » Sun Feb 22, 2015 6:04 pm

I never knew that we could use newlione as a token.

Very neat find :)
B
28
S
8
G
4
Posts: 767
Reputation: 5,950

Post » Mon Oct 12, 2015 5:52 pm

Hey man, I'm just trying to do the same with a text file, but i'm not really good at using tokenats and parsing text... Could you please upload an example of how to do this? :(
PD. your pictures are deleted.
B
21
S
4
G
1
Posts: 6
Reputation: 2,186


Return to How do I....?

Who is online

Users browsing this forum: AllanR, Yahoo [Bot] and 10 guests