User Tag List

Results 1 to 8 of 8

Thread: How would YOU delete all blank lines from List Object?

  1. #1
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    ratty's Avatar
    Join Date
    Apr 2012
    Posts
    1,165
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    How would YOU delete all blank lines from List Object?

    I've done this a few ways now but none of them seems as concise as it should be. I had a good working method but it stopped working for some reason...

    Anyway, having a list that's populated during runtime, how would you have all blank lines removed from it (assuming they interspersed among lines with text)?

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,366
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    This is tested and works fine:

    Set the list to be base 0 indexed.
    Make a counter.
    Run a loop as many times as there are lines in the list.

    * On loop
    + line at Counter1 is blank

    - List: delete line at current value of Counter1
    - Counter1: sub one

    * On loop
    - Counter1: add 1

  3. #3
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's an alternative that doesn't need a counter, but needs to re-create the entire list (in other words, you may want to stick to Popcorn's solution)

    Start out like in Popcorn's example:
    0 based index list.
    Run the loop as many times as there are lines in the list.

    * On loop
    + line at 0 <> blank
    - List: Add line [text of line 0]

    * On loop
    - List: Delete line 0

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module

    Join Date
    May 2012
    Location
    NSW, Australia
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well i would've thought it would be as simple as this:

    Run a loop, with number of lines from the list as the number of iterations.

    On Loop "delete"
    + ListLineText$("List", Loopindex("delete")) = ""
    Delete line Loopindex("delete").


    However, i just tried that and you have to run the loop a couple of times to get rid of all the lines....... anyone know why this is? logically to me it seems like it should work, but it doesn't?

    EDIT: Workaround is adding in an action to restart the loop. effectively keeps going until all blank lines are deleted. Example MFA is included!

    On Loop "delete"
    + ListLineText$("List", Loopindex("delete")) = ""
    Delete line Loopindex("delete").
    Start Loop "delete", for: numberOfLines(list).

    EXAMPLE MFA

  5. #5
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    However, i just tried that and you have to run the loop a couple of times to get rid of all the lines....... anyone know why this is? logically to me it seems like it should work, but it doesn't?
    It doesn't work because the line indexes changes every time you remove a line. If for example line 3 is blank, and it is removed, the next line you want to check will also be line number 3, not 4.

    EDIT: Workaround is adding in an action to restart the loop. effectively keeps going until all blank lines are deleted. Example MFA is included!
    That's not a good solution. For each non-blank line, you recurse and run the fastloop another List Nb Lines( "List" ) times. In your example, the fastloop is triggered 336 times. Both Popcorn's and my solutions runs the fastloop as many times as there are lines, no more.

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module

    Join Date
    May 2012
    Location
    NSW, Australia
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Nifflas View Post
    It doesn't work because the line indexes changes every time you remove a line. If for example line 3 is blank, and it is removed, the next line you want to check will also be line number 3, not 4.
    That's not a good solution. For each non-blank line, you recurse and run the fastloop another List Nb Lines( "List" ) times. In your example, the fastloop is triggered 336 times. Both Popcorn's and my solutions runs the fastloop as many times as there are lines, no more.
    Well that makes alot of sense now!
    Just tried the solutions you and popcorn made and as you mentioned they are much more efficient!

  7. #7
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    ratty's Avatar
    Join Date
    Apr 2012
    Posts
    1,165
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Macca02 found the same issue I did. Popcorn and Nifflas, awesome examples. That solves the repetition issue!

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ratty - just come across a novel way to do this, based on a bug I just found in List object: simply save your list, reset and load it back - all blank lines will be removed!
    Of course, if this really is a bug, then it may get fixed soon, so perhaps not a good idea to rely on it just yet:
    http://community.clickteam.com/threads/81524-List-Object-txt-file-load-removing-blank-lines?p=598901#post598901

Similar Threads

  1. Bug: Exception on searching INIs with blank lines
    By DavidN in forum XNA Export Module Version 2.0
    Replies: 1
    Last Post: 4th September 2013, 05:58 AM
  2. List Object txt file load removing blank lines
    By AyreGuitar in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 7th July 2013, 09:40 AM
  3. [bug] list object BLANK in unicode version
    By StingRay in forum Android Export Module Version 2.0
    Replies: 1
    Last Post: 10th April 2013, 11:39 AM
  4. [bug] list object BLANK in unicode version
    By StingRay in forum Android Export Module Version 2.0
    Replies: 0
    Last Post: 10th April 2013, 08:47 AM
  5. Blank lines in INI file
    By DavidN in forum XNA Export Module Version 2.0
    Replies: 5
    Last Post: 11th October 2012, 07:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •