was an easy fix I had forgot to declare the variable. Here is the corrected script:
Code:
//
//===========================================================================
// ORIGINAL:
// Script : track_announce.pal
// Author : newagecelticmusic
// New Age & Celtic Classics
// http://www.newagecelticmusic.com
//
// Date : April 4, 2009
//
//
// CURRENT:
// Script : year_announce.pal
// Author : watcher407
// SlamminTunes
// http://www.slammintunes.com
//
// Date : July 15, 2014
// Purpose: Inserts the song year before the track
//
// Notice : Give credit where credit is due! Don't remove the
// header information from this script or extremely
// bad karma will result!
//
//============================================================================
//
// Declarations
//
var QueQuery : TDataSet;
var SongQuery : TDataSet;
var recID : Integer;
var artist : String;
var albumyear : String;
var filename : String;
var annpath : String;
//
// Setup
//
// All of your yearly announce tracks need to be in one directory, and must be
// formatted as yyyy.mp3 - EX 2009.mp3 2010.mp3! Change the directory below
// with your directory, and do not forget the trailing slash!
//
annpath := 'C:\announce_year\';
//
Pal.Loop := True;
//
//
Pal.LockExecution;
//
QueQuery := Query('SELECT * from samdb.queuelist order by id',[],True);
If QueQuery.IsEmpty then
begin
// Adjust Category name below as needed - creating a fail safe to keep SAM from crashing
CAT['Music (All)'].QueueTop(smRandom, NoRules);
Pal.UnLockExecution;
end
else
QueQuery.First;
recID := QueQuery['songid'];
QueQuery.Free;
SongQuery := Query('SELECT * from samdb.songlist where id = ' + IntToStr(recID),[],True);
If SongQuery.IsEmpty then
begin
// Adjust Category name below as needed - creating a fail safe to keep SAM from crashing
CAT['Music (All)'].QueueTop(smRandom, NoRules);
WriteLn('Track added, no track initially found!');
Pal.UnLockExecution;
end
else
albumyear := LowerCase(SongQuery['albumyear']);
SongQuery.Free;
filename := StringReplace(albumyear,' ','',True);
filename := annpath + filename + '.mp3';
If FileExists(filename) then
begin
WriteLn('Adding ' + filename + ' to queue');
Queue.AddFile(filename,ipTop);
Pal.UnLockExecution;
PAL.WaitForPlayCount(2);
end
else
begin
WriteLn('Can not find ' + filename + ' ... waiting for next song');
Pal.UnLockExecution;
PAL.WaitForPlayCount(1);
end