Trim newline-seperated string to last 10 lines?

This forum is currently in read-only mode.
From the Asset Store
80 pieces of loopable game music, 10 game overs and 10 level complete pieces.
  • Every few seconds I want to load a newline-separated text file to a text box, but I only want to display the last few lines. This wouldn't be a problem if I could scroll the text box, but I can't (or don't know how to), so... can anyone help?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You might be able to use GetToken(), and NumTokens()

    For example, let's say you're storing the file contents in a global named file_contents, i.e., Global: Set 'file_contents' to File.LoadFileToString(AppPath & "file.txt")

    Well, NumTokens(global('file_contents'),NewLine) should tell you how many lines there are in the file_contents global.

    So, you could possibly do this:

    For "loopname" from NumTokens(global('file_contents'),NewLine) - 10 to NumTokens(global('file_contents'),NewLine):

    with the action: System: Set 'somevar' to global('somevar') & GetToken(global('file_contents'),LoopIndex,NewLine)

    And set your text box to show global('somevar')

    Or you could clear the text box's text first, and instead have your action set the text box's text to: Editbox.Text & GetToken(global('file_contents'),LoopIndex,NewLine) ..if it's an editbox.

    I hope I made enough sense. I'm tired.

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