Note that this Wiki is a work in progress, items may not be updated or may disappear entirely as the pages are updated.

PAL script to clear songs from categories and then fill them back up

From SpacialAudio

Jump to: navigation, search

This PAL script clears a set of categories and then fills them up with a new set of songs. this was done with help from Louis. Infact the adding songs back in to the categories came from Louis. This script runs daily at 6pm. It clears 4 categories and then puts songs back into the categories.


PAL.Loop := True;
PAL.WaitForTime(T['18:00:00']); {Wait for 6pm}
const Cats : String = 'ORHP';
var D, D2 : TDataSet;
var C : Integer;
var Current : String;
var mytime : DateTime = now;
  //DELETE songs from categories 
  For C := 1 to Length(Cats) do
  begin
     Current := Cats[C];
     D2:=Query('SELECT ID, name  FROM category WHERE name = :cat', [Current], True);
     writeln ('Deleting songs from category ' + D2['name']);
     ExecSQL('DELETE FROM categorylist WHERE categoryID = :categoryID', [D2['ID']]);
  end; 
  D2.free ;
  //Start PAL for filling categories.
  PAL.LockExecution;
  For C := 1 to Length(Cats) do
  begin
     Current := Cats[C];
     WriteLn('Adding file to '+Current);
     D := Query('select * from songlist, categorylist where songlist.id=categorylist.songID and categorylist.categoryID = 4 and UPC = :UPC',[Current],True);
     D.First;
     while not D.EOF do
     begin
        CAT[Current].AddFile(D['filename'],ipBottom);
        D.Next;
     end;
     D.Free;
  end;
  PAL.UnlockExecution;   
PAL.WaitForTime(T['23:59:59']); {Wait for next day}
Personal tools