GetItemType

Hello all,

In a notification script, in OnPlayerStart, I search to get the item type.
I tried with Item.GetItemType, GetIconData but it return a mismatch error…

[code]procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);

begin
SystemLog(‘Current Iten Type: ’ +Item.GetItemType +’’)
end;

begin
end.[/code]

Thanks for your help

You need a semicolon at the end of the SystemLog line.

Also, GetItemType does NOT return a string; it returns a member of the tPlaylistItemType enumeration list (which will be a number), so you can’t directly add it to a string. What you CAN do is compare it with one or more of the possible tPlaylistItemType values, something like this:

var piType: TPlaylistItemType; ... piType := Item.GetItemType(); case piType of pitMusic: <something>; pitVoice: <something>; pitNews: <something>; ... end;

… where each is one statement or a block of code wrapped in a begin/end.

You can find a complete list of the playlist item type names in the mAirListScript.chm file:
Units > mAirListTypes > Types > TPlaylistItemType

BFN
Cad

Thanks Cad your help.
My final code written from samples of your “AddIconByType” script.

[code]procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);

var
CurrentItemType: string;
piType: TPlaylistItemType;

begin

piType := Item.GetItemType();
CurrentItemType := '';

case piType of
  pitMusic:        CurrentItemType := 'MUSIC';
  pitVoice:        CurrentItemType := 'VOICE';
  pitNews:         CurrentItemType := 'NEWS';
  pitAdvertising:  CurrentItemType := 'ADVERTISING';
  pitPackage:      CurrentItemType := 'PACKAGE';
  pitJingle:       CurrentItemType := 'JINGLE';
  pitSound:        CurrentItemType := 'SOUND';
  pitEffect:       CurrentItemType := 'EFFECT';
  pitTrailer:      CurrentItemType := 'TRAILER';
  pitPromo:        CurrentItemType := 'P0ROMO';
  pitSponsorship:  CurrentItemType := 'SPONSORSHIP';
  pitSweeper:      CurrentItemType := 'SWEEPER';
  pitDrop:         CurrentItemType := 'DROP';
  pitStationID:    CurrentItemType := 'STATIONID';
  pitBed:          CurrentItemType := 'BED';
  pitInstrumental: CurrentItemType := 'INSTRUMENTAL';
  pitShow:         CurrentItemType := 'SHOW';
  pitOther:        CurrentItemType := 'OTHER';
  pitCustom1:      CurrentItemType := 'CUSTOM1';
  pitCustom2:      CurrentItemType := 'CUSTOM2';
  pitCustom3:      CurrentItemType := 'CUSTOM3';
  pitCustom4:      CurrentItemType := 'CUSTOM4';
end;

if CurrentItemType <> '' then
begin
  SystemLog('Current Iten Type: ' + CurrentItemType +'');
end 
else begin
  SystemLog('Current Iten Type:  Not Set');
end;

end;

begin
end.
[/code]

Bingo! (That’s where I cribbed the example code from! :wink: )

There are a few typos in your code, though:

[tt] pitPromo: CurrentItemType := ‘P0ROMO’;

if CurrentItemType <> '' then
begin
  SystemLog('Current Ite[b]n[/b] Type: ' + CurrentItemType +'');
end 
else begin
  SystemLog('Current Ite[b]n[/b] Type:  Not Set');
end;

[/tt]
Finally, if you change:

[code] piType := Item.GetItemType();
CurrentItemType := ‘’;

case piType of

[/code]
to:

CurrentItemType := 'Not Set'; case Item.GetItemType() of
then you can also change:

if CurrentItemType <> '' then begin SystemLog('Current Iten Type: ' + CurrentItemType +''); end else begin SystemLog('Current Iten Type: Not Set'); end;
to:

SystemLog('Current Item Type: ' + CurrentItemType);
… and then you don’t need the piType variable at all.

However, if you plan to do ‘other stuff’ in your script, you might want to keep piType to use later in your script.

BFN
Cad

Thanks Cad for these correctiones.