How would YOU delete all blank lines from List Object?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • 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)?

  • 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

  • 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

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

    Please login to see this link.

    Edited 6 times, last by macca02 (June 8, 2013 at 7:32 AM).

  • Quote

    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.

    Quote

    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.

    Edited once, last by Nifflas (June 8, 2013 at 11:34 AM).

  • 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!

  • 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:
    Please login to see this link.

    Kevin Ayre Please login to see this link.
    My iOS Apps: Please login to see this link., Please login to see this link. and Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!