Thank you again for sutch quick answers! I have the PAL beginner manual here and I'm reading it all time!
Well, I got the script working... but there is still one question to be answerd:
The SQL returns a value of 12:00:00 AM, but there is no row in the database that holds that information, why do i keep getting this information?
Here is the full version of the script:
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
{ About:
This script will play a remote show inside SAM
The show starts at a specified time, and then ends at
another specified time.
The script also contains some error-correction code
that will attempt to connect to the stream up to 20 times
in case it goes down. We schedule one song between each attempt.
}
{Declare variables}
var NumWeekend, NumWeek, NumDay : Integer;
var TimeBegin, TimeEnd : datetime;
NumWeekend := 100;
NumWeek := 100;
var D : TDataSet;
{ CONFIGURATION }
{==================================================}
const ShowURL = 'http://url.org:6600/';
{ SQL Get time }
{==================================================}
{Get current day}
if DayOfWeek(Now) = Sunday then
begin
NumDay := 0;
NumWeekend := 8;
end;
if DayOfWeek(Now) = Monday then
begin
NumDay := 1;
NumWeek := 7;
end;
if DayOfWeek(Now) = Tuesday then
begin
NumDay := 2;
NumWeek := 7;
end;
if DayOfWeek(Now) = Wednesday then
begin
NumDay := 3;
NumWeek := 7;
end;
if DayOfWeek(Now) = Thursday then
begin
NumDay := 4;
NumWeek := 7;
end;
if DayOfWeek(Now) = Friday then
begin
NumDay := 5; NumWeekend := 8;
end;
if DayOfWeek(Now) = Saturday then
begin
NumDay := 6;
NumWeekend := 8;
end;
{Make SQL Query}
D := Query('SELECT t_program_tid_start, t_program_tid_slut FROM tabla WHERE (t_dag = :NumDay) or (t_dag = :NumWeek) or (t_dag = :NumWeekend) ORDER BY t_program_tid_start ASC LIMIT 1',[NumDay, NumWeek,NumWeekend],True);
D.First;
while not D.EOF do
begin
TimeBegin := D['t_program_tid_start'];
WriteLn(TimeBegin);
TimeEnd := D['t_program_tid_slut'];
D.Next;
end;
D.Free;
if(TimeBegin > T['-00:00:30']) and (TimeBegin < T['+00:00:30']) then
begin
{ Wait for next broadcast }
{==================================================}
PAL.WaitForTime(TimeBegin);
{ IMPLEMENTATION }
{--------------------------------------------------}
var T : Integer;
PAL.Loop := True;
{Wait for the show to start}
PAL.WaitForTime(TimeBegin);
{Add show to queue}
Queue.Clear;
Queue.AddURL(ShowURL,ipTop);
{Fade to show}
ActivePlayer.FadeToNext;
{Precautions - if there is a brief disconnect or server problem,
then we would want to retry a few times to get back to the show.
To do this we place the URL quite a few times in the queue, followed
by some normal programmming. That way we will try and reconnect until
the end of the show}
T := 0;
while T < 20 do
begin
Queue.AddURL(ShowURL,ipBottom);
CAT['New'].QueueBottom(smLRP,EnforceRules);
T := T + 1;
end;
{Wait for show to end}
PAL.WaitForTime(TimeEnd);
{Add show to queue}
Queue.Clear;
{Fade to normal programming}
ActivePlayer.FadeToNext;
{End of if-time}
end;
{ Loop this script }
PAL.Loop := True;
//Sebbe