DBScript SetType

Hello!

I’m trying to use SetType in a database script but it’s failing with message ‘UNKNOWN IDENTIFIER’

I’m using SetColor, SetComment and a few others fine - Am I using the wrong keyword?

oResult.SetColor($4080FF); oResult.SetType('Error'); oResult.SetComment('Artist last played at XX - Exceeds 2 hour artist repeat policy');

oResult.SetItemType(pitError);

(“pit” prefix = “playlist item type”)

Works like a charm!

Thanks :slight_smile:

So after playing a bit more…

Having some trouble with SetItemType

If I try SetItemType(pitMusic) all good.

So I tried SetItemType(rs.GetString(2)) with that string being ‘Music’… No Luck
Tried the same, but with that string being pitMusic… No Luck. Do you have any suggestions for that?

Additionally…

Finding that SetColor is behaving… Differently to what I’d expect? If I want hex #FF0000 I have to enter SetColor($0000FF)?

You cannot use strings as PlaylistItemType constants. You must do something like this:

if rs.GetString(2) = 'Music' then oResult.SetItemType(pitMusic)
else if rs.GetString(2) = 'News' then oResult.SetItemType(pitNews)
...

That’s pretty much like how mAirList does it internally.

Colors: Delphi’s colors are BGR, not RGB as in HTML, so HTML #AABBCC translates to $CCBBAA.

http://delphi.wikia.com/wiki/Colors_in_Delphi

OK Perfect - That makes sense, thanks.

In that case, based on what you’re saying - I’m not going to be able to pull a color from the database either?

Unless I did

if rs.GetString(2) = ‘$EEFF00’ then oResult.SetColor($EEFF00)

Use StrToInt for that: http://www.delphibasics.co.uk/RTL.asp?Name=strtoint

Unlike other languages like PHP or JavaScript, Delphi is “strongly typed”, which means that you must explicitly convert between strings, numbers, etc. - you cannot just use a string where the function expects a number, etc.

Ah my confusion there being that hex isnt an integer… But then I woke up tiny bit and remembered it is. Thanks again.

For anyone who comes accross this in the future - The below converts the text to PlaylistItemType (The text/string is identical to how it is represented in the GUI in the current version of mAirList)

			if rs.GetString(2) = 'Music' then oResult.SetItemType(pitMusic);
            if rs.GetString(2) = 'Voice Track' then oResult.SetItemType(pitVoice);
            if rs.GetString(2) = 'News' then oResult.SetItemType(pitNews);
            if rs.GetString(2) = 'Weather' then oResult.SetItemType(pitWeather);
            if rs.GetString(2) = 'Traffic' then oResult.SetItemType(pitTraffic);
            if rs.GetString(2) = 'Advertising' then oResult.SetItemType(pitAdvertising);
            if rs.GetString(2) = 'Package' then oResult.SetItemType(pitPackage);
            if rs.GetString(2) = 'Jingle' then oResult.SetItemType(pitJingle);
            if rs.GetString(2) = 'Sound' then oResult.SetItemType(pitSound);
            if rs.GetString(2) = 'Sound Effect' then oResult.SetItemType(pitEffect);
            if rs.GetString(2) = 'Trailer' then oResult.SetItemType(pitTrailer);
            if rs.GetString(2) = 'Promo' then oResult.SetItemType(pitPromo);
            if rs.GetString(2) = 'Sponsorship' then oResult.SetItemType(pitSponsorship);
            if rs.GetString(2) = 'Sweeper' then oResult.SetItemType(pitSweeper);
            if rs.GetString(2) = 'Drop' then oResult.SetItemType(pitDrop);
            if rs.GetString(2) = 'Station ID' then oResult.SetItemType(pitStationID);
            if rs.GetString(2) = 'Bed' then oResult.SetItemType(pitBed);
            if rs.GetString(2) = 'Instrumental' then oResult.SetItemType(pitInstrumental);
            if rs.GetString(2) = 'Show' then oResult.SetItemType(pitShow);
            if rs.GetString(2) = 'Stream' then oResult.SetItemType(pitStream);
            if rs.GetString(2) = 'Container' then oResult.SetItemType(pitContainer);
            if rs.GetString(2) = 'Playlist' then oResult.SetItemType(pitPlaylist);
            if rs.GetString(2) = 'Command' then oResult.SetItemType(pitCommand);
            if rs.GetString(2) = 'Break' then oResult.SetItemType(pitBreak);
            if rs.GetString(2) = 'Dummy' then oResult.SetItemType(pitDummy);
            if rs.GetString(2) = 'Silence' then oResult.SetItemType(pitSilence);
            if rs.GetString(2) = 'Error' then oResult.SetItemType(pitError);
            if rs.GetString(2) = 'Other' then oResult.SetItemType(pitOther);
            if rs.GetString(2) = 'Custom 1' then oResult.SetItemType(pitCustom1);
            if rs.GetString(2) = 'Custom 2' then oResult.SetItemType(pitCustom2);
            if rs.GetString(2) = 'Custom 3' then oResult.SetItemType(pitCustom3);

OK Final question, promise!

Any possibility of adding in Alpha channel support?

If not, I’ll have a word with the person choosing those colors! Ha.