Text Manipulator skipping lines?

For questions about using Classic.

Post » Wed Aug 08, 2012 11:17 pm

Hello, looking for a quick bit of help with the Text Manipulator object that doesn't seem to have been addressed elsewhere on the forum. I'm trying to use it to store some simple scripts for cutscenes / NPC scripted actions in a text file. I've got a few simple events in just to make sure it's reading the file line-by-line properly by filling a text box with the lines:

TextManip: Load file "scripts.txt"
-> For each substring, delimited by NewLine -> textbox: Set text to textbox.Text + NewLine + TextManip.GetCurrentSubString

When I do this, it only writes every second line into the text box. What am I doing wrong, here? Can't quite figure out how it delimits substrings.
B
1
G
1
Posts: 4
Reputation: 433

Post » Thu Aug 09, 2012 12:02 am

DO you understand how the tokenizer works?

f.e a command could be

string , token , string etc

the token (any character of choice) will separate a string.
So by loading the raw string you can extract multiple strings from it

f.e

hello#cat#monkey#

if the token is # then the following strings can be extracted

hello, cat and monkey

hello is 1, cat 2 and monkey 3



Urled2012-08-09 00:03:55
B
18
S
4
G
1
Posts: 413
Reputation: 2,512

Post » Thu Aug 09, 2012 12:22 am

Thanks for the quick reply.

I think I get it, yeah. My understanding was that using "NewLine" as the delimiter in the For Each would use the line breaks in the text file as the token, making each SubString = one line of the text file. Which could then be used to fill up the text box by, For Each SubString, setting it to its current contents + a line break (NewLine) + the current substring.

But as I say, when I do that it only writes every second line, implying there's more than I'm seeing in how it separates the string with NewLine.
B
1
G
1
Posts: 4
Reputation: 433

Post » Thu Aug 09, 2012 1:52 am

To read line by line of the text file using the text manipulator, use the "read line by line" action.

Example:
+ System: Start of layout
-> TextManipulator: Read file AppPath & "mytext.txt" line by line
++ TextManipulator: On line read
--> Text: Set text to .Text & TextManipulator.GetReadLine & NewLine
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Thu Aug 09, 2012 9:32 am

Ahh, that works, thanks Tulamide. Still don't understand why the For Each wasn't working, but whatever, this'll do for now. Cheers!
B
1
G
1
Posts: 4
Reputation: 433

Post » Sun Feb 28, 2016 12:34 am

I also want to write a plain text file. I need that the project can continuously store new data. I created a kind of database with a TXT file. Since not exist in Construct2 some that can be manipulated such as a MySQL database. But I don't know writing in my text file "data.txt"...
B
23
S
8
G
1
Posts: 36
Reputation: 2,052

Post » Sun Feb 28, 2016 8:23 am

@yofabianuy
yofabianuy wrote:I also want to write a plain text file. I need that the project can continuously store new data. I created a kind of database with a TXT file. Since not exist in Construct2 some that can be manipulated such as a MySQL database. But I don't know writing in my text file "data.txt"...


Did you intend to post this in a 4 year old dead thread for a retired piece of software (Construct Classic)?
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,844
Reputation: 48,289


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests