Thanks for that!
The file need to be signed to work without problems. Works poorly if it is in any of the Windows special folders.
Got to move it to my c:\000 workfolder to get it to work.
Adapted from Torben’s scripts\notification\LogItemsToFile.mls script:
function FileExists(sFileName: string): boolean;
var
sl: TStringList;
begin
sl := TStringList.Create;
try
// wrap loading in a try..except block in case the file does not exist
try
Result := true;
sl.LoadFromFile(sFileName);
except
Result := false;
end;
finally
sl.Free;
end;
end;
You might also find some of my scripts useful and hopefully educational. The ZIPfiles contain fully-commented versions as well as ‘stripped’ ones to make them run slightly faster.
[quote=“patrikekman, post:3, topic:7216”]The file need to be signed to work without problems. Works poorly if it is in any of the Windows special folders.
Got to move it to my c:\000 workfolder to get it to work.[/quote]
I don’t know how to sign that file. You probably need to register with Microsoft to obtain a key or so.
From my experience, you just need to uncheck the “ask me every time” box in the “warning, this is a downloaded file” dialog that appears when you open it for the first time. All pages will show fine then, even when the file is on a network share or so.
But can not find a function for Fileexists()?
Looks like it’s not imported by Pascal Script by default. I will add it. The workaround mentioned by Cad will work for the moment, but it’s only practical for small files. (Not a good idea to read a 500 MB WAV file into a string list just to check if the file exists.)
(Note that most of the functions imported directly from Delphi aren’t mentioned in the CHM file - it’s only about mAirList’s internal interfaces.)
In Windows 7, it gets funny (security) and won’t show the content pages. If you right-click the file, click on Properties then click “Unblock”, then all is well. Certainly doesn’t need to be signed here.
I’m darned if I can find it in the CHM right now, but the syntax is: Playlist(playlist-index-number).LoadFromFile(filename-string);
or just: CurrentPlaylist.LoadFromFile(filename-string);
if you have only one Playlist. Playlists are numbered from zero upwards.
To Insert (rather than Load) the file, use this instead of .LoadFromFile: .InsertFile(item-number, filename-string) item-number is the item number in the Playlist after which you want to Insert the file.
I don’t think there’s a .AppendFile, but you could fake one like this:
procedure AppendFileToCurrentPlaylist(sFilename : string);
var
iItemCount: integer;
begin
iItemCount := CurrentPlaylist.GetCount;
CurrentPlaylist.InsertFile(iItemCount, sFilename);
end;
Hope that helps.
Oh: and to answer your question about M3Us, the InsertFile method can handle M3Us, MLPs, or single audio files; so yes, you can import/insert/append M3Us.