INTERACT FORUM

More => Old Versions => JRiver Media Center 31 for Windows => Topic started by: rbmjr on February 10, 2024, 02:01:25 pm

Title: I am confused about Fields, specifically when to use square brackets
Post by: rbmjr on February 10, 2024, 02:01:25 pm
Attached and included are two nearly identical versions of the same code. The only difference are the inclusion/exclusion of the square brackets around the field name. The unbracketed field name works, however the bracketed field name does not. I'd like to use the SetField command with date fields too, but I don't know how to tell the SetField command that it is receiving the raw value? [mydatefield,0] vs [mydatefield,1] or should it be coded SetField(mydatefield, [workdate,0]). Guidance please.

RMX - V:8

if( IsPlaying() ,

>>>>

If( IsEmpty( [WorkList1x] ), Save( , GVWorkList2x ), Save( [WorkList1x] , GVWorkList2x ) )
If( IsEmpty( [SmartList] ), Save( , GVWorkList1x ), Save( [SmartList] , GVWorkList1x ) )
SetField( [WorkList2x], Load( GVWorkList2x ) )
SetField( [WorkList1x], Load( GVWorkList1x ) )

If( IsEmpty( [Last Played] ), Save( , GVLastPlayed ), Save( FormatDate( [Last Played,0] , dd MM yyyy ) , GVLastPlayed ) )

If( IsEmpty( [WorkDate1x] ), Save( , GVWorkDate2x ), Save( FormatDate( ConvertDate( [WorkDate1x] ), dd MM yyyy ) , GVWorkDate2x ) )
If( IsEmpty( [Last Played] ), Save( , GVWorkDate1x ), Save( FormatDate( ConvertDate( [Last Played,0] ), dd MM yyyy ) , GVWorkDate1x ) )
SetField( [WorkDate2x], FormatDate( ConvertDate( Load( GVWorkDate2x) ), MM//dd//yyyy ) )
SetField( [WorkDate1x], FormatDate( ConvertDate( Load( GVLastPlayed) ), MM//dd//yyyy ) )

SetField( WorkString, LP: FormatDate( ConvertDate( Load( GVLastPlayed) ), MM//dd//yyyy ) WL1x: Load( GVWorkList1x ) WD1x: FormatDate( ConvertDate( Load( GVWorkDate1x ) ), MM//dd//yyyy ) WL2x: Load( GVWorkList2x ) WD2x: FormatDate( ConvertDate( Load( GVWorkDate2x ) ), MM//dd//yyyy ) )
,
FormatDate( Now(), datetime )
)


RMX - V:9

if( IsPlaying() ,

>>>>

If( IsEmpty( [WorkList1x] ), Save( , GVWorkList2x ), Save( [WorkList1x] , GVWorkList2x ) )
If( IsEmpty( [SmartList] ), Save( , GVWorkList1x ), Save( [SmartList] , GVWorkList1x ) )
SetField( WorkList2x, Load( GVWorkList2x ) )
SetField( WorkList1x, Load( GVWorkList1x ) )

If( IsEmpty( [Last Played] ), Save( , GVLastPlayed ), Save( FormatDate( [Last Played,0] , dd MM yyyy ) , GVLastPlayed ) )

If( IsEmpty( [WorkDate1x] ), Save( , GVWorkDate2x ), Save( FormatDate( ConvertDate( [WorkDate1x] ), dd MM yyyy ) , GVWorkDate2x ) )
If( IsEmpty( [Last Played] ), Save( , GVWorkDate1x ), Save( FormatDate( ConvertDate( [Last Played,0] ), dd MM yyyy ) , GVWorkDate1x ) )
SetField( WorkDate2x, FormatDate( ConvertDate( Load( GVWorkDate2x) ), MM//dd//yyyy ) )
SetField( WorkDate1x, FormatDate( ConvertDate( Load( GVLastPlayed) ), MM//dd//yyyy ) )

SetField( WorkString, LP: FormatDate( ConvertDate( Load( GVLastPlayed) ), MM//dd//yyyy ) WL1x: Load( GVWorkList1x ) WD1x: FormatDate( ConvertDate( Load( GVWorkDate1x ) ), MM//dd//yyyy ) WL2x: Load( GVWorkList2x ) WD2x: FormatDate( ConvertDate( Load( GVWorkDate2x ) ), MM//dd//yyyy ) )
,
FormatDate( Now(), datetime )
)
Title: Re: I am confused about Fields, specifically when to use square brackets
Post by: Matt on February 10, 2024, 02:04:36 pm
Brackets return the value in that field so you don't want them.
Title: Re: I am confused about Fields, specifically when to use square brackets
Post by: markf2748 on February 10, 2024, 04:22:45 pm
@zybex's ZELDA is a great utility tool for working with expressions:
https://yabb.jriver.com/interact/index.php?topic=125975.0 (https://yabb.jriver.com/interact/index.php?topic=125975.0)
If you have not done so already, then try it!  In general, start simple and add complexity as needed.
Title: Re: I am confused about Fields, specifically when to use square brackets
Post by: rbmjr on February 10, 2024, 06:47:50 pm
I will check out ZELDA, all that Notepad++ does is help match parenthesis.
Title: Re: I am confused about Fields, specifically when to use square brackets
Post by: zybex on February 11, 2024, 04:13:01 am
To answer your question: the brackets are used to get the current value of the field, and that's what is usually wanted. However for some functions like SetValue() and Load() we want to indicate the name of the field, not its value. So no brackets required.

Btw, Load(field) can be replaced by just [field], even for saved variables.
Title: Re: I am confused about Fields, specifically when to use square brackets
Post by: rbmjr on February 11, 2024, 09:27:39 am
Thanks, did not know that global variables could be referenced using the square brackets.