Daily 24 Hour Rotation

1. Daily 24 Hour Rotation
This PAL script will pick tracks out of designated folders at specific times of the day, and queue them to play. You WILL need to tweek your AutoRotation settings so that it doesn’t interfere with the script and vice versa.

{
   This script plays the following program

    1.   8am, monday, tuesday, wednesday thursday or friday   World Music     1h
    2.   11am monday, wedneday or thursday                    Electronic      1h
    3.   12 noon, monday, wednesday, thursday or friday       World Music   0.5h
    4.   4pm, on Monday or Wednseday                          Country Music   1h
    5.   9pm, Monday, Tuesday or Wednesday                    World Music     1h
    6.   7am, Sunday					      Christian       1h
    7.   8pm, Winter Cissy                                    Chinese DJ      1h
    
    
  To Create New Events, simply recreate the code between the comments
  // Event x
  ....
  // End of Event x
  
  Remembering to add any (var Catx : string, and Catx := 'string'; 's that you
  need.
}




PAL.Loop := True;
var D: Integer;       // return from SQL calls
var F : Boolean;      // switch to controll additional activities in events.
var E : DateTime = Queue.ETA;    // Return the length of the queues

// Create as many of these as you have categories you are going to use.
var CatA : string;
var CatB : string;
var CatC : string;
var CatD : string;
var CatE : string;
var CatF : string;
var CatG : string;
var CatH : string;
var CatI : string;  // Addrd 23/06/09 for WinterCissy segment


// I know it could be simplified, but I'm making a point.

CatA := 'World';
CatB := 'HatMusic';
CatC := 'Electronic';
CatD := 'Christian';
CatE := 'Animals';
CatF := 'Comedy';
CatG := 'Pop';
CatH := 'Bargrooves';
CatI := 'WinterCissyMix1'; // Added 23/06/09


F := false;

// Event One
// Is it 8am, monday, tuesday, wednesday thursday or friday? And between 8am & 9am
// Play World Music
// WriteLn(DayOfWeek(Now) );
if (now >= T['07:58:00']) and (now <= T['07:59:00']) and
((DayOfWeek(Now) = Monday) or 
(DayOfWeek(Now) = Tuesday) or 
(DayOfWeek(Now) = Wednesday) or 
(DayOfWeek(Now) = Thursday) or 
(DayOfWeek(Now) = Friday)) then
         begin
            Queue.Clear;
               repeat
                  cat[CatA].QueueTop(smLRP,EnforceRules);
               until (Queue.Duration >= 3360000);
               // 56 minutes  of world music
            F := true;
         end;         
   if (F) then                        // If F is true. set in queue load above.
      begin
         WriteLn('Wait for 1 track');
         PAL.WaitForPlayCount(1);
         // wait for one track to play
      end;
   if (F) then
      begin
         D:=ExecSQL('UPDATE showstatus SET event = "World Music Hour" WHERE ID = 1',[]);
         WriteLn('World Music Hour');   // this displays in the pal window.
      end;
   if (F) then
      begin
         E := Queue.ETA;
         WriteLn('Time to wait');
         WriteLn(E);
         PAL.WaitForTime(E);
         // ok, hang about for the length of the queue.
      end;
   if (F) then
      begin
         D:=ExecSQL('UPDATE showstatus SET event = "The Quantum Daily Mix" WHERE ID = 1',[]);
         WriteLn('Quantum Daily Mix');
         F := false;
         // It's now after 9am, so back to the normal daily Mix.
         // This is every day except Sat, and Sun
      end;
// End of Event One
// ===============================================
// Event One A added Monday 21 October 2007
// Is it 8am, monday, tuesday, wednesday thursday or friday? And between 8am & 9am
// Play World Music
// WriteLn(DayOfWeek(Now) );
if (now >= T['10:38:00']) and (now <= T['10:39:00']) and
((DayOfWeek(Now) = Monday) or
(DayOfWeek(Now) = Tuesday) or
(DayOfWeek(Now) = Wednesday) or
(DayOfWeek(Now) = Thursday) or
(DayOfWeek(Now) = Friday)) then
         begin
            Queue.Clear;
               repeat
                  cat[CatA].QueueTop(smLRP,EnforceRules);
               until (Queue.Duration >= 3360000);
               // 56 minutes  of world music
            F := true;
         end;
   if (F) then                        // If F is true. set in queue load above.
      begin
         WriteLn('Wait for 1 track');
         PAL.WaitForPlayCount(1);
         // wait for one track to play
      end;
   if (F) then
      begin
         D:=ExecSQL('UPDATE showstatus SET event = "World Music Hour" WHERE ID = 1',[]);
         WriteLn('World Music Hour');   // this displays in the pal window.
      end;
   if (F) then
      begin
         E := Queue.ETA;
         WriteLn('Time to wait');
         WriteLn(E);
         PAL.WaitForTime(E);
         // ok, hang about for the length of the queue.
      end;
   if (F) then
      begin
         D:=ExecSQL('UPDATE showstatus SET event = "The Quantum Daily Mix" WHERE ID = 1',[]);
         WriteLn('Quantum Daily Mix');
         F := false;
         // It's now after 9am, so back to the normal daily Mix.
         // This is every day except Sat, and Sun
      end;
// End of Event One


// ===============================================
// Event Two. F now False again
// Is it 11am monday, wedneday or thursday?
if (now >= T['10:58:00']) and (now <= T['10:59:00']) and
((DayOfWeek(Now) = Monday) or 
(DayOfWeek(Now) = Wednesday) or 
(DayOfWeek(Now) = Thursday)) then
         begin
            Queue.Clear;
               repeat
                  cat[CatG].QueueTop(smLRP,EnforceRules);
               until (Queue.Duration >= 3360000);
               // Stuff 56 minutes worth of Pop into the queue.
            F := true;
         end;         
   if (F) then
      begin
         WriteLn('Wait for 1 track');
         PAL.WaitForPlayCount(1);
         // wait to play one track
      end;
   if (F) then
      begin
         WriteLn('Updating the show');
         D:=ExecSQL('UPDATE showstatus SET event = "Electronic Madness" WHERE ID = 1',[]);
      end;
   if (F) then
      begin
         E := Queue.ETA;
         WriteLn('Time to wait');
         WriteLn(E);
         PAL.WaitForTime(E);
      end;
   if (F) then
      begin
         D:=ExecSQL('UPDATE showstatus SET event = "The Quantum Daily Mix" WHERE ID = 1',[]);
         WriteLn('Quantum Daily Mix');
         F := false;
         // The hour of Pop is over, back to the daily mix.
         // Remember, this is Mon, Wed and Thu only.
      end;
      
      
// Event Three
// Is it 12 Midday, Monday, Wednesday, Thursday or Friday?
if (now >= T['11:58:00']) and (now <= T['11:59:00']) and
((DayOfWeek(Now) = Monday) or
(DayOfWeek(Now) = Wednesday) or
(DayOfWeek(Now) = Thursday) or
(DayOfWeek(Now) = Friday)) then
   begin
      Queue.Clear;
      Queue.AddFile('F:\My Documents\RadioDaze\StationPromo\SoundEffects\Peacock.mp3',ipBottom);
      // Get the listeners attention. This is a klaxon...
   repeat
      cat[CatA].QueueBottom(smRandom,EnforceRules);
      cat[CatA].QueueBottom(smRandom,EnforceRules);
      cat[CatA].QueueBottom(smLRP,EnforceRules);
      cat[CatA].QueueBottom(smLRP,EnforceRules);
   until (Queue.Duration >= 1680000);
       // Load 28 minutes of music ( about half an hour !!! )
      Queue.AddFile('F:\My Documents\RadioDaze\StationPromo\SoundEffects\Peacock.mp3',ipBottom);
      // Get the listeners attention. This is a klaxon... 5 seconds
      F := true;
   end;
if (F) then
   begin
      WriteLn('Waiting for one song to play...');
      PAL.WaitForPlayCount(1);
      // play one track then continue
   end;
if (F) then
   begin
      D:=ExecSQL('UPDATE showstatus SET event = "The Weekly Sampler" WHERE ID = 1',[]);
      WriteLn('The Weekly Sampler');
   end;
if (F) then
   begin
      WriteLn('Wait for 10 Minutes');      
      PAL.WaitForTime(T['+00:10:00']);
   end;
if (F) then
   begin
      Queue.AddFile('F:\My Documents\RadioDaze\StationPromo\SoundEffects\Peacock.mp3',ipTop);
      // Blow them away with the dive dive dive klaxton...
   end;
if (F) then
   begin
      E := Queue.ETA;
      WriteLn('Time to wait');
      WriteLn(E);
      PAL.WaitForTime(E);
      // Wait for the que to end.
   end;
if (F) then
   begin
      D:=ExecSQL('UPDATE showstatus SET event = "The Quantum Daily Mix" WHERE ID = 1',[]);
      WriteLn('Quantum Daily Mix');
      F := false;
      // ok, back to the normal scheduling.
   end;
   
// Event Four.
// Is it 4pm, on Monday or Wednseday?
if (now >= T['15:58:00']) and (now <= T['15:59:00']) and
((DayOfWeek(Now) = Monday) or 
(DayOfWeek(Now) = Wednesday)) then
         begin
            Queue.Clear;
               repeat
               // Load an hour of Country
                  cat[CatB].QueueTop(smLRP,EnforceRules);
               until (Queue.Duration >= 3360000);
            F := true;
         end;         
   if (F) then
      begin
         WriteLn('Wait for 1 track');
         PAL.WaitForPlayCount(1);
      end;
   if (F) then
      begin
         WriteLn('Updating the show');
         D:=ExecSQL('UPDATE showstatus SET event = "The Best of Country" WHERE ID = 1',[]);
      end;
   if (F) then
      begin
         E := Queue.ETA;
         WriteLn('Time to wait');
         WriteLn(E);
         PAL.WaitForTime(E);
         // Play the queue
      end;
   if (F) then
      begin
         D:=ExecSQL('UPDATE showstatus SET event = "The Quantum Daily Mix" WHERE ID = 1',[]);
         WriteLn('Quantum Daily Mix');
         F := false;
         // ok, back to the normal scheduling
      end;
      
// Event Five.
// Is it 9pm, Monday, Tuesday or Wednesday?
if (now >= T['20:58:00']) and (now <= T['20:59:00']) and ((DayOfWeek(Now) = Monday) or 
(DayOfWeek(Now) = Tuesday) or 
(DayOfWeek(Now) = Wednesday)) then
         begin
            Queue.Clear;
               repeat
               // Load an hour of WORLD for now
                  cat[CatA].QueueTop(smLRP,EnforceRules);
               until (Queue.Duration >= 3360000);
             F := true;
         end;         
   if (F) then
      begin
         WriteLn('Wait for 1 track');
         PAL.WaitForPlayCount(1);
      end;
   if (F) then
      begin

         D:=ExecSQL('UPDATE showstatus SET event = "The Sabbath Hour" WHERE ID = 1',[]);
         WriteLn('The Sabbath Hour');
      end;
   if (F) then
      begin
         E := Queue.ETA;
         WriteLn('Time to wait');
         WriteLn(E);
         PAL.WaitForTime(E);
      end;
   if (F) then
      begin
         D:=ExecSQL('UPDATE showstatus SET event = "The Quantum Daily Mix" WHERE ID = 1',[]);
         WriteLn('Quantum Daily Mix');
         F := false;
      end;
// end of event
// Event Six.
// Is it 7am, on Sunday?
if (now >= T['07:58:00']) and (now <= T['07:59:00']) and
((DayOfWeek(Now) = Sunday)) then
         begin
            Queue.Clear;
               repeat
               // Load an hour of Christian
                  cat[CatD].QueueTop(smLRP,EnforceRules);
               until (Queue.Duration >= 3360000);
            F := true;
         end;
   if (F) then
      begin
         WriteLn('Wait for 1 track');
         PAL.WaitForPlayCount(1);
      end;
   if (F) then
      begin
         WriteLn('Updating the show');
         D:=ExecSQL('UPDATE showstatus SET event = "The Mission Station Hour" WHERE ID = 1',[]);
      end;
   if (F) then
      begin
         E := Queue.ETA;
         WriteLn('Time to wait');
         WriteLn(E);
         PAL.WaitForTime(E);
         // Play the queue
      end;
   if (F) then
      begin
         D:=ExecSQL('UPDATE showstatus SET event = "The Quantum Daily Mix" WHERE ID = 1',[]);
         WriteLn('Quantum Daily Mix');
         F := false;
         // ok, back to the normal scheduling
      end;
// ====================================================
// Event Seven
// ===============================================




Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA * Time limit is exhausted. Please reload CAPTCHA.