Text search

Discussion and feedback on Construct 2

Post » Sun Jun 29, 2014 9:20 pm

After you've read and converted, why not just save as json, then import the file into your project. You could then just Ajax request the file and your off.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
131
S
29
G
81
Posts: 5,328
Reputation: 56,630

Post » Sun Jun 29, 2014 10:18 pm

Which was just what I ended up doing. :-)

solved, I think.
There is nothing obvious about retrieving data from webstorage outside a project, so I worked around it.
The way to get 32000 words into an array is:

1. read the data from a text file with newline as separator into an array using:
Import the text file into the project.
AJAX request the file.
repeat tokencount(AJAX.Lastdata,newline) times
Array push back tokenat(AJAX.LastData,loopindex,newline) on X axis.
(this will take close to a minute)

2. Use NodeWebKit and run preview with NodeWebkit as selected browser.
Save (on click of a button or whatever) to file , with Array.AsJson as content.

3. This gives a txt file, correctly json-formatted, which can now be imported into project, AJAX requested and loaded directly into the Array. (Remember to use "AJAX on completed" before attempting a load into Array with
Array Load from Json string AJAX.lastdata.

And this only takes a second.

Well, I learned a bit from this, and thanks to codah and zenox98 for nudging me along. :-)
B
5
S
1
Posts: 23
Reputation: 471

Post » Sun Jun 29, 2014 11:37 pm

I think what I did was log the JSON text to the debug console then just copy and paste it to a text file and put it in the files folder under my project folder, reimporting it with Ajax.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Jun 30, 2014 9:39 am

Which just goes to prove that C2 and its users are flexible in approaches to a challenge. :-)
B
5
S
1
Posts: 23
Reputation: 471

Post » Thu Mar 26, 2015 1:08 pm

@codah

codah wrote:here's the capx I used.

array_search.capx


Hello,

Would you be so kind to share that your capx again?

Thanx!
B
26
S
11
G
2
Posts: 669
Reputation: 5,038

Previous

Return to Construct 2 General

Who is online

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