js how to handle lists that have empty elements.

    Sep 23 2013 | 10:56 am
    Im iterating out multiple lists in js like this:
    0 0 tracks track1 0 0 tracks track2 0 0 tracks track3
    However, sometimes I might have an empty element at the end of the list:
    0 0 tracks
    I would like to be able to detect that the last list element is empty. I cant seem to do this inside the js object, or outside in Max.
    In Max, ive tried using "zl len" to detect the size of the list, but Max seems to believe that the list element is there, even though it is empty.
    The same goes for inside the js object. Ive tried using
    if (var[3] == "")
    Even though the part of the list is empty, there seems to be no way of recognising that it is empty.
    Id be really grateful if anyone has any insights to a way of working around this.
    UPDATE: Finally ive got it "if (var[3] == 0)"

    • Sep 23 2013 | 3:36 pm
      An array in js always of the length property. You can probably do something like:
      if (yourvar.length < 3)
    • Sep 23 2013 | 3:52 pm
      If your problem is that the last item of the list may be an empty string, you could use [sadam.empty] to detect that.
      HTH, Ádám
    • Sep 23 2013 | 5:45 pm
      removing it or replacing it with the symbol "zzz" might be also an option.