0 Favourites

Text Manipulator skipping lines?

This forum is currently in read-only mode.
  • 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.

  • 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

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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.

  • 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

  • Ahh, that works, thanks Tulamide. Still don't understand why the For Each wasn't working, but whatever, this'll do for now. Cheers!

  • 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"...

  • yofabianuy

    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)?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)