INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: I am confused about Fields, specifically when to use square brackets  (Read 728 times)

rbmjr

  • World Citizen
  • ***
  • Posts: 124

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 )
)
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42387
  • Shoes gone again!
Re: I am confused about Fields, specifically when to use square brackets
« Reply #1 on: February 10, 2024, 02:04:36 pm »

Brackets return the value in that field so you don't want them.
Logged
Matt Ashland, JRiver Media Center

markf2748

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 825
Re: I am confused about Fields, specifically when to use square brackets
« Reply #2 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
If you have not done so already, then try it!  In general, start simple and add complexity as needed.
Logged

rbmjr

  • World Citizen
  • ***
  • Posts: 124
Re: I am confused about Fields, specifically when to use square brackets
« Reply #3 on: February 10, 2024, 06:47:50 pm »

I will check out ZELDA, all that Notepad++ does is help match parenthesis.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: I am confused about Fields, specifically when to use square brackets
« Reply #4 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.
Logged

rbmjr

  • World Citizen
  • ***
  • Posts: 124
Re: I am confused about Fields, specifically when to use square brackets
« Reply #5 on: February 11, 2024, 09:27:39 am »

Thanks, did not know that global variables could be referenced using the square brackets.
Logged
Pages: [1]   Go Up