Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2006
    Posts
    13

    How to ignore line starting by # caractere

    Hi,
    I'm trying to populate a listbox with an m3U (playlist) file. The purpose of this is to pick and launch a song from that listbox in the media player.

    The script I use is:

    function playlist()
    ListBox.DeleteItem("ListBox1",-1);
    tbFiles = TextFile.ReadToTable();
    for i,v in tbFiles do
    ListBox.AddItem("ListBox1", String.SplitPath(v).Filename, v);
    end
    end

    Every things work fine with the script except that the list include with each song a line of caractere that I wish to eliminate. In the example below these lines start by #EXTINF...

    ex:
    #EXTM3U
    #EXTINF:248,Bill Evans - Nancy (with the Laughing Face)
    Bill Evans - Nancy (with the Laughing Face)
    #EXTINF:351,Bill Evans - Nardis
    Bill Evans - Nardis
    #EXTINF:490,Bill Evans - No Cover, No Minimum
    Bill Evans - No Cover, No Minimum
    etc.

    I found a tread in this forum arguing that AMS could ignore lines with # at the beginning of the line. Could anyone help me with the necessary code to do so that the result will appear like this in the listbox.

    Bill Evans - Nancy (with the Laughing Face)
    Bill Evans - Nardis
    Bill Evans - No Cover, No Minimum
    etc.

    Thanks

    D.

  2. #2
    Join Date
    Feb 2001
    Location
    Indigo Rose Software
    Posts
    2,728
    Something like this might work:

    Code:
    function playlist() 
      ListBox.DeleteItem("ListBox1",-1);
      tbFiles = TextFile.ReadToTable();
      for i,v in tbFiles do
        if(String.Left(v, 1) ~= "#") then
          ListBox.AddItem("ListBox1", String.SplitPath(v).Filename, v);
        end
      end
    end
    --[[ Indigo Rose Software Developer ]]

  3. #3
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    NM. Lorne beat me to it.
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  4. #4
    Join Date
    Oct 2006
    Posts
    13
    Yess so simple and logic.

    Many thanks Lorne for your help.

  5. #5
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    You can also use the lua string.find to look for lines that begin with a # and ignore them.

    function playlist()
    ListBox.DeleteItem("ListBox1",-1);
    tbFiles = TextFile.ReadToTable();
    for i,v in tbFiles do
    if not string.find(v, "^#") then
    ListBox.AddItem("ListBox1", String.SplitPath(v).Filename, v);
    end
    end
    end
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  6. #6
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    And this should ignore leading space characters. You could do the same thing using String.Trim within AMS.

    function playlist()
    ListBox.DeleteItem("ListBox1",-1);
    tbFiles = TextFile.ReadToTable();
    for i,v in tbFiles do
    if not string.find(v, "%S^#") then
    ListBox.AddItem("ListBox1", String.SplitPath(v).Filename, v);
    end
    end
    end
    The %S is a capital S which says ignore space characters
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  7. #7
    Join Date
    Oct 2006
    Posts
    13

    Thumbs up

    Very well TJ-Tigger,
    It's also getting the job done. I can figure how it works now.
    Thank you Sir. There's a lot to learn in here.
    D.

Similar Threads

  1. Line numbers...confusing?
    By bucksommerkamp in forum TrueUpdate 2.0
    Replies: 1
    Last Post: 07-25-2005, 02:05 PM
  2. Function: Parsing Command Line Arguments
    By Brett in forum AutoPlay Media Studio 5.0 Examples
    Replies: 0
    Last Post: 05-13-2004, 08:42 AM
  3. Email Input Text ??
    By octane6228 in forum AutoPlay Media Studio 5.0
    Replies: 25
    Last Post: 02-21-2004, 03:59 PM
  4. HOWTO: Build a Setup from the Command Line
    By Support in forum Setup Factory 5.0
    Replies: 0
    Last Post: 10-08-2002, 01:43 PM
  5. HOWTO: Build a Setup from the Command Line
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 09-27-2002, 02:16 PM

Posting Permissions

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