INTERACT FORUM

Please login or register.

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

Author Topic: Please add Global Variable usage in the Add Rules section of Smartlists  (Read 404 times)

rbmjr

  • World Citizen
  • ***
  • Posts: 112

I thought that I could use a global variable in the Add Rules section, however it seems that global variables only work in the Modify Results section (see attachment). Could you please add Global Variable usage in the Add Rules section?
Logged

mark_h

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1854

You need to use the Custom rule in the Add Rules section and build your own test that way.

Custom: [=compare([last played],>,load(gvRandom)]]=1

Or something like that.  It quite often helps to add an expression column to your view and work on this expression there until you have it right, and then move it into the smartlist rules, otherwise you spend a lot of time fiddling with that dialogue while you work through the code.

The stuff in the [] is your test - the =1 outside is the smartlist test for positivity, ie if your rule is true and the result should be included.
Logged

rbmjr

  • World Citizen
  • ***
  • Posts: 112

Thanks, I'll give that a try. I always wondered what the []=1 was for
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2422

The syntax for the left side is [=expression]; this expression can return any value which you then compare using the normal Smartlist operators. So for an expression that returns 0 or 1, you may do [=expression]=1, but for other cases you may want [=expression]="English","United States" or [=expression]=>3 for instance.
Logged

mark_h

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1854

Thanks, Zybex, I didn't know that!  That opens up some opportunities :D
Logged

dtc

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3020

Just to add - 0 and 1 are just computer values for FALSE and TRUE.  So, =1 just means that the previous expression is TRUE.
Logged

rbmjr

  • World Citizen
  • ***
  • Posts: 112

I finally figured it out.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2422

The expression syntax is wrong, it should be:
[=compare([last played,0],<,math(now()-rand(60,90,1)))]=1

Your expression will always return 1 for any file due to how if() works with an invalid expression ("=<" is not valid in there)
(this applied to the expression on the previous screenshot, now replaced)
Logged

rbmjr

  • World Citizen
  • ***
  • Posts: 112

still have questions. So there is no need to preface [Last Played,0] with Math() in this compare statement:

[=Compare( Math( [Last Played, 0] ), < , Math( Now() - Load(GVRandom) ) )]=1

If I wanted to increase/decrease months or years when performing math on the value of Now() is there an easy way to do this as in:

Math( Now() + 1, y) or Math( Now() + 3, M)
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2422

Dates are measured in days, so you can do Math(Now()-31) or Math(Now()-365). If you need precise dates it gets a bit more complicated.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8963

If you need precise dates it gets a bit more complicated.
Don't they just. I still say a silent "thank you" to you (and Matt) for your help with leap years whenever I'm working in that area.

rbmjr

  • World Citizen
  • ***
  • Posts: 112

I learn so much through the Forum, thanks to everyone who helped.
Logged
Pages: [1]   Go Up