Advanced Conditional Scripting

You are missing a feature or need an enhancement? Post your suggestion here!
inl_inc
Posts: 76
Joined: 12 Dec 2013 18:42
Re: Advanced Conditional Scripting

Post by inl_inc »

Note, that the script-line Filter effectively evaluates/applies to the tracks of the given library - so it filters 'certain' tracks out of all available!
In your example above ({$currentSystemTime}=<'hh:mm:ss(my upper threshold)'...) it sounds, that this wouldn't make sense to be used in a filter; as the system date/time isn't an attribute of a track such filter would either always fail or match for all tracks!
I see what you mean now ... seems the filter is set up to take the [trackField] and an argument. I tried to write something like this, where the system time condition comparison would be independent of the track characterstics (in itself)

('${HH}${mm}${ss}'<120000 And [dayPartCode] = 'morning') OR ('${HH}${mm}${ss}'>=120000 And [dayPartCode] = 'afternoon') //on second thought that MADE NO SENSE

I guess what i'm looking for is to be able to write the following in the filter:
if (${HH}${mm}${ss}<120000) {
[dayPartCode] = 'morning'
} else {
[dayPartCode] = 'evening'
}

The idea behind this, is that I generally have the same clockwheel structure for each program, for argument's sake lets say PowerHit/Gold/PowerHit/New/Break (repeat to fill hour). However, I might consider a particular PowerHit track to not be appropriate for the morning (so I'd add a respective flag to the track). Then the filter logic based on system time comparisons would allow me to run the same script throughout the day, but also daypart the clockwheel.
So that example more sounds like a real script-line condition, e.g. do not use this script-line during morning hours...?
Yes this alternative solution would definitely result in the same outcome. The only drawback to me, is that i would have to enter each scripted track twice (i.e. once to pick morning track, then pick afternoon track - with mutually exclusive filters). This makes the script somewhat harder to read. But I will be happy with whatever implementation you choose - if it accomplishes the same goal at the end.
inl_inc
Posts: 76
Joined: 12 Dec 2013 18:42
Re: Advanced Conditional Scripting

Post by inl_inc »

ProppFrexx rocks!!! I wonder how many other feature are already built-in and we just don't know about them ...
Going to try this out now.
I actually use the Rating field for day parting, mainly because it defaults to zero which represents "can be played at any time"
User avatar
radio42
Site Admin
Posts: 6551
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Advanced Conditional Scripting

Post by radio42 »

Depending on what 'Rating' really contains in your setup/tagging...
it might be (if rating contains either '0', 'morning' or 'evening'):

Code: Select all

~[Rating] == '*[IF:{${HH}}:{LessEq(12)}:{morning}:{evening}]' Or [Rating] == '0'
or (if rating contains the numeric minimum hour, e.g. 12 if it can play up until 12 o'clock):

Code: Select all

~[Rating] <= ${HH}
inl_inc
Posts: 76
Joined: 12 Dec 2013 18:42
Re: Advanced Conditional Scripting

Post by inl_inc »

Bernd thanks for the additional info - I see the potential of what can be done with this IF function. However, I'm having trouble getting the IF to resolve in the filter. I tried doing something super simple as a test, screenshot below the IF should have returned either 'Ultravox' or 'Silencers', and there are definitely results in the library as illustrated by addition of the Or conditions.
Attachments
if_filter.jpg
if_filter.jpg (83 KiB) Viewed 6035 times
inl_inc
Posts: 76
Joined: 12 Dec 2013 18:42
Re: Advanced Conditional Scripting

Post by inl_inc »

oh did another quick test by writing to a text file ...
'*[IF:${HH}:LessEq(12):Ultravox:Silencers]' --> resolved to ''

tried this syntax in the exec_write_file
'*[IF:{${HH}}:{LessEq(12)}:{Ultravox}:{Silencers}]' --> did resolve to 'Ultravox'

but when I tried syntax 2 in the filter --> still no results
inl_inc
Posts: 76
Joined: 12 Dec 2013 18:42
Re: Advanced Conditional Scripting

Post by inl_inc »

Yes - just figured that out myself.

The IFs work!!! --> had to use the syntax with the {} brakers between :.

Thanks for showing me how to do this!
User avatar
radio42
Site Admin
Posts: 6551
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Advanced Conditional Scripting

Post by radio42 »

I am sorry, but the macros are currently ONLY working within the scripting, but not in the Find Expression builder.
This because I first wanted to provide something for you to play with and then integrate it into other elements as well.
E.g. the track macros (${genre} for example) wouldn't be available in the regular find, as that would have access resp. wouldn't know anything about a 'last scheduled' track.

So to test the macros within the script-line filters you must actually use them and test them, with a real running script.
User avatar
radio42
Site Admin
Posts: 6551
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Advanced Conditional Scripting

Post by radio42 »

In that case you might try something which should be possible today - the *IF macro function (see the Appendix in the User Manual for details).

Assume your 'daypart' ('morning' or 'evening' value) code is stored somewhere inside the 'Grouping' field.
Normally you might use this Filter:

Code: Select all

~Contains([Grouping], 'morning')
But now you want to make the constant value 'morning' be more dynamic, i.e. when the system time (hour) is less or equal to 12 it should use 'morning, else it should use 'evening'.

So you might try a Filter something like this:

Code: Select all

~Contains([Grouping], '*[IF:{${HH}}:{LessEq(12)}:{morning}:{evening}]')
As you can see, the constant 'morning' is replaced by the *IF macro function.
Explanation: The *IF macro function returns a value depending on a condition.
All macros are replaced within the Filter at the time is executed.
As such, the *IF expression will result into the string 'morning' or 'evening' depending on the given condition, which is ${HH} must be less or equal 12.
As such , the above will result to:
When the system time is e.g. 11 o'clock:

Code: Select all

~Contains([Grouping], 'morning')
And when the system time is e.g. 17 o'clock:

Code: Select all

~Contains([Grouping], 'evening')
Guess this is what you are looking for?!

Note: I am using the Contains Filter function, since Grouping might also contain other values; which you want to use in other meanings...
E.g. a track's [Grouping] value might for example be tagged as this "Hot; morning; Classics".
User avatar
radio42
Site Admin
Posts: 6551
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Advanced Conditional Scripting

Post by radio42 »

In v3.0.14.4 I have now added support for the macro filters (conditional filters) also for the script rules as well as for any Find Window.
So you could now also test your macros in the Filter/Find Expression Builder...

Post Reply