PDA

View Full Version : mind boggling file insert problem



gnetcanada
02-20-2004, 10:09 AM
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
02-20-2004, 11:40 AM
file_tablewma is probably nil. You should test it too, not just file_tablewav. :)

I'm guessing you might want something llike this:

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_tablewma == nil then
file_tablewma = {};
end

if file_tablewav ~= nil then
for i, file in file_tablewav do
Table.Insert(file_tablewma, 1, file);
end
endThis 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

gnetcanada
02-20-2004, 11:52 AM
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!

Lorne
02-20-2004, 12:55 PM
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.

Corey
02-20-2004, 01:46 PM
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 (http://www.indigorose.com)

Lorne
02-20-2004, 02:43 PM
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 (http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=soothe)" and not "sooth (http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=sooth)" which Webster's doesn't actually list as a verb...although of course that doesn't prove that it isn't a verb... :)

Corey
02-20-2004, 03:00 PM
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 (http://www.indigorose.com)

gnetcanada
02-20-2004, 03:05 PM
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?

TJ_Tigger
02-20-2004, 03:23 PM
Originally posted by Lorne
I think you mean "soothe (http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=soothe)" and not "sooth (http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=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 (http://dictionary.reference.com/search?q=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?

gnetcanada
02-20-2004, 03:27 PM
using the windows media plugin

Corey
02-20-2004, 03:28 PM
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 (http://www.indigorose.com)

TJ_Tigger
02-20-2004, 03:45 PM
gnetcanada,

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


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



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

TJ_Tigger
02-20-2004, 03:54 PM
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.

:D :D :D :D :D

Lorne
02-20-2004, 05:37 PM
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. :)

Corey
02-20-2004, 05:42 PM
assauge

Knew you'd love that. :)

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)