Scripting-Hilfe: Nützliche Funktionen und Prozeduren

Leider kann man den Elementtyp mit der Abfrage Item.GetItemType nicht direkt verwerten, siehe hier. Allen, die so etwas trotzdem brauchen, sei hier eine Funktion dafür an die Hand gelegt, etwas eleganter als im obigen Beispiel:

function ItemType(Item: IPlaylistItem): string;
begin
  case Ord(Item.GetItemType) of
    0: Result := 'Unknown';
    1: Result := 'Music';
    2: Result := 'Voice';
    3: Result := 'News';
    5: Result := 'Traffic';
    6: Result := 'Advertising';
    7: Result := 'Package';
    8: Result := 'Jingle';
    9: Result := 'Sound';
    10: Result := 'Trailer';
    11: Result := 'Promo';
    12: Result := 'Sponsorship';
    13: Result := 'Sweeper';
    14: Result := 'Drop';
    15: Result := 'StationID';
    16: Result := 'Bed';
    17: Result := 'Instrumental';
    18: Result := 'Show';
    19: Result := 'Stream';
    20: Result := 'Container';
    21: Result := 'Playlist';
    22: Result := 'Command';
    23: Result := 'CartwallPage';
    24: Result := 'Break';
    25: Result := 'Dummy';
    26: Result := 'Silence';
    27: Result := 'Error';
    28: Result := 'Other';
    29: Result := 'Custom1';
    30: Result := 'Custom2';
    31: Result := 'Custom3';
  else
    Result := 'NULL';
  end;
end;


Mit der Abfrage
var
  Element: string;
  Item: IPlaylistItem;

begin
  Element := ItemType(Item);
end.

läßt sich der Elementtyp direkt als String ausgeben.

Ergänzte Grüße

TSD