mind boggling file insert problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • gnetcanada
    Indigo Rose Customer
    • May 2003
    • 83

    mind boggling file insert problem

    Hi Guys,

    This doesnt work,

    No matter what i do, it says "On Timer Line X argument 1 must be of type table"

    Line X is :Table.Insert(file_tablewma, 1, file);

    Here is all the code, for some reason is file_table not the right type of table? This doesnt make sense!

    file_table = File.Find(ssfolder, "*.mp3", subfolder, false, nil);
    file_tablewav = File.Find(ssfolder, "*.wav", subfolder, false, nil);
    file_tablewma = File.Find(ssfolder, "*.wma", subfolder, false, nil);

    if file_tablewav ~= nil then
    for i, file in file_tablewav do
    Table.Insert(file_tablewma, 1, file);
    end
    end
  • Lorne
    Indigo Rose Staff Member
    • Feb 2001
    • 2729

    #2
    file_tablewma is probably nil. You should test it too, not just file_tablewav.

    I'm guessing you might want something llike this:
    Code:
    file_table = File.Find(ssfolder, "*.mp3", subfolder, false, nil); 
    file_tablewav = File.Find(ssfolder, "*.wav", subfolder, false, nil); 
    file_tablewma = File.Find(ssfolder, "*.wma", subfolder, false, nil); 
    
    [COLOR=blue]if file_tablewma == nil then
        file_tablewma = {};
    end[/COLOR]
    
    if file_tablewav ~= nil then 
        for i, file in file_tablewav do 
            Table.Insert(file_tablewma, 1, file); 
        end 
    end
    This assumes you want to use file_tablewma to hold both wav and wma files, even if there are no wma files found. I would recommend renaming the variables a bit to reflect the broader nature of file_tablewma, btw, to avoid future confusion
    --[[ Indigo Rose Software Developer ]]

    Comment

    • gnetcanada
      Indigo Rose Customer
      • May 2003
      • 83

      #3
      thats not the problem, file_tablewma is not nill, it always has something in it! the insert command is just not aknowledging it as a table!

      Comment

      • Lorne
        Indigo Rose Staff Member
        • Feb 2001
        • 2729

        #4
        Prove to me that the file_tablewma is not nil at that point, and I'll believe you.

        Especially considering the documentation for File.Find's return value:

        Returns
        (table) A table containing the paths to all of the files that were found. If no files were found or an error occurs, nil is returned. You can use Application.GetLastError to determine whether this action failed, and why.
        Are you sure that there are wma files in that folder? If there aren't, file_tablewma is going to be set to nil by the File.Find action.
        --[[ Indigo Rose Software Developer ]]

        Comment

        • Corey
          Indigo Rose Staff Alumni
          • Aug 2002
          • 9745

          #5
          I'm paraphrasing but Lorne once mentioned that the mere lack of proof of something doesn't necessarily preclude it and that this technique of implying reverse onus should be avoided when making a point or position. Which leads us to the fact that I'm glad I am not sitting within Lorne's punching range right now as I mention this.

          But seriously, this post is, of course, intended purely to sooth Lorne and nothing more. :o

          Corey Milner
          Creative Director, Indigo Rose Software

          Comment

          • Lorne
            Indigo Rose Staff Member
            • Feb 2001
            • 2729

            #6
            Originally posted by Corey
            But seriously, this post is, of course, intended purely to sooth Lorne and nothing more. :o
            I think you mean "soothe" and not "sooth" which Webster's doesn't actually list as a verb...although of course that doesn't prove that it isn't a verb...
            --[[ Indigo Rose Software Developer ]]

            Comment

            • Corey
              Indigo Rose Staff Alumni
              • Aug 2002
              • 9745

              #7
              Yes I did mean "soothe", sorry I was trembling with laughter at the time and couldn't spell properly as a result. It was mainly meant to assauge any concerns you may have had that I don't listen to you, thereby soothing you into a feeling of well being. Kind of indirect but awful sweet of me nonetheless don't you think?

              Corey Milner
              Creative Director, Indigo Rose Software

              Comment

              • gnetcanada
                Indigo Rose Customer
                • May 2003
                • 83

                #8
                all im effectively trrying to do is merge tablewav into table, so i can have all the wav files in the file_table as well, maybe there is better way to do this?

                Comment

                • TJ_Tigger
                  Indigo Rose Customer
                  • Sep 2002
                  • 3159

                  #9
                  Originally posted by Lorne
                  I think you mean "soothe" and not "sooth" which Webster's doesn't actually list as a verb...although of course that doesn't prove that it isn't a verb...
                  I thought maybe you meant sloth. Try to slow down his typing rampage.


                  But seriously, has there been a change with the MP3 support and AMS5? There seems to be a rush of posts in the forum lately that mention searching for MP3 files. Are people wanting to play the MP3 files with AMS5 or are they using another third party program?
                  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

                  Comment

                  • gnetcanada
                    Indigo Rose Customer
                    • May 2003
                    • 83

                    #10
                    using the windows media plugin

                    Comment

                    • Corey
                      Indigo Rose Staff Alumni
                      • Aug 2002
                      • 9745

                      #11
                      I thought maybe you meant sloth.
                      HAR! That's the funniest thing I've heard in here in a long time. Tigg get's my "Ahoy of the Month" AND a golden thumb! "Slow Loris" is one of my very favorite things to say, has been for years...

                      Yes MP3 support was deprecated in 5.0 due to patent madness. You can play an MP3 though using the media player object if you need to. Or Flash object, or any of many web object plug-ins, etc... Personally I convert to OGG. OGG is much better quality.

                      Corey Milner
                      Creative Director, Indigo Rose Software

                      Comment

                      • TJ_Tigger
                        Indigo Rose Customer
                        • Sep 2002
                        • 3159

                        #12
                        gnetcanada,

                        Here is one way to merge tables. If you are planning on having multiple tables I would also look into building a function.

                        Code:
                        mp3_table = {"file1.mp3", "file2.mp3", "file3.mp3", "file4.mp3", "file5.mp3"}
                        wav_table = {"file1.wav", "file2.wav", "file3.wav", "file4.wav", "file5.wav"}
                        wma_table = {"file1.wma", "file2.wma", "file3.wma", "file4.wma", "file5.wma"}
                        
                        master_audio_table = {}
                        
                        if (Table.Count(mp3_table)> 0 ) then
                        	for i,v in mp3_table do
                        		Table.Insert(master_audio_table, Table.Count(master_audio_table) +1, v)
                        	end
                        end
                        if (Table.Count(wav_table)> 0 ) then
                        	for i,v in wav_table do
                        		Table.Insert(master_audio_table, Table.Count(master_audio_table) +1, v)
                        	end
                        end
                        if (Table.Count(wma_table)> 0 ) then
                        	for i,v in wma_table do
                        		Table.Insert(master_audio_table, Table.Count(master_audio_table) +1, v)
                        	end
                        end
                        
                        for i,v in master_audio_table do
                        	Dialog.Message("file"..i,"the name of your file is "..v,MB_OK,MB_ICONINFORMATION,MB_DEFBUTTON1)
                        end
                        If you were to build a function you could do this

                        Code:
                        --as defined on Global Functions page
                        function TableMerge(mastertable, addtable)
                             if (Table.Count(addtable)> 0 ) then
                        	for i,v in addtable do
                        		Table.Insert(mastertable, Table.Count(mastertable) +1, v)
                        	end
                             end
                        end
                        
                        --to use you will need to have your tables you want to merge
                        mp3_table = {"file1.mp3", "file2.mp3", "file3.mp3", "file4.mp3", "file5.mp3"}
                        wav_table = {"file1.wav", "file2.wav", "file3.wav", "file4.wav", "file5.wav"}
                        wma_table = {"file1.wma", "file2.wma", "file3.wma", "file4.wma", "file5.wma"}
                        
                        --[[and define your master table as well  
                        you could define a check as part of your function that if this 
                        did not exist you could then create the table
                        if mastertable == nil then
                        mastertable = {}
                        end]]--
                        master_audio_table = {}
                        
                        --Then run your functions
                        TableMerge(master_audio_table,mp3_table)
                        TableMerge(master_audio_table,wav_table)
                        TableMerge(master_audio_table,wma_table)
                        Last edited by TJ_Tigger; 02-20-2004, 02:48 PM.
                        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

                        Comment

                        • TJ_Tigger
                          Indigo Rose Customer
                          • Sep 2002
                          • 3159

                          #13
                          Originally posted by Corey
                          HAR! That's the funniest thing I've heard in here in a long time. Tigg get's my "Ahoy of the Month" AND a golden thumb! "Slow Loris" is one of my very favorite things to say, has been for years...

                          Yes MP3 support was deprecated in 5.0 due to patent madness. You can play an MP3 though using the media player object if you need to. Or Flash object, or any of many web object plug-ins, etc... Personally I convert to OGG. OGG is much better quality.
                          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

                          Comment

                          • Lorne
                            Indigo Rose Staff Member
                            • Feb 2001
                            • 2729

                            #14
                            Originally posted by Corey
                            Yes I did mean "soothe", sorry I was trembling with laughter at the time and couldn't spell properly as a result. It was mainly meant to assauge any concerns you may have had that I don't listen to you, thereby soothing you into a feeling of well being.
                            Quit laughing already!

                            Kind of indirect but awful sweet of me nonetheless don't you think?
                            Yeah. Outright odorous.
                            --[[ Indigo Rose Software Developer ]]

                            Comment

                            • Corey
                              Indigo Rose Staff Alumni
                              • Aug 2002
                              • 9745

                              #15
                              assauge
                              Knew you'd love that.

                              Corey Milner
                              Creative Director, Indigo Rose Software

                              Comment

                              Working...
                              X