if genres undefined then...
if genres undefined then...
hi
if genres is undefined then use ...
how to?
if genres is undefined then use ...
how to?
Re: if genres undefined then...
e.g.
@see viewtopic.php?f=5&t=1895
Code: Select all
any{genres}{'No Genres'}
Re: if genres undefined then...
thanks but i want if genres are defined then do nothing! else if genres are undefined write "qwerty"
Re: if genres undefined then...
He answered you...did you not see it?
any{genres}{'No Genres'}
simply change No Genres to whatever you want..
any{genres}{'qwerty'}
any{genres}{'No Genres'}
simply change No Genres to whatever you want..
any{genres}{'qwerty'}
Re: if genres undefined then...
no dear friend i don't want write genres when genres are defined!!!
only i want write"qwerty" when genres are undefined
for example i have 3 movies
1- Crash-[1080p]-[Crime].mkv
2- Lukochuri-[480p]-[].mkv
3- Blue Jay-[1080p]-[Drama].mkv
i want first and third movies go to "movies" folder no "drama" or "crime" folder!!!
but second movie that hasn't genre go to "qwerty" folder
do you see???
Re: if genres undefined then...
I gotcha.... So you are wanting to do a simple if then else statement. If genre is defined ignore it...and if it isn't defined then use xxxxxx folder.
That is how I start my code. It verifies the size of the movie (4k, HD, SD) and puts the movies into the correct folder. So for your case, try this (M is my media drive...use whatever yours is instead.):
Code: Select all
M:/{vf == /2160p/ ? 'Movies 4K' : vf =~ /1080p|720p/ ? 'Movies HD' : 'Movies'}
Code: Select all
M:/{genre == null ? "qwerty" : "Movies"}/
Re: if genres undefined then...
You could do this:
This code works due to the Unwind-on-Undefined Behaviour. Checking for null won't work, because the {genres} does not yield a null value when undefined, but throws an exception yielding no value at all.
@see viewtopic.php?f=5&t=1895
Code: Select all
any{genres; "Yes Genres"}{"No Genres"}

@see viewtopic.php?f=5&t=1895
Re: if genres undefined then...
Ahhh.. I tested it using other fields as I don't have any movies currently that don't have a genre listed. I wasn't aware it wouldn't give a null. And I was so proud of being able to help someone. DOH! LOLrednoah wrote: ↑23 Mar 2018, 06:21 You could do this:Code: Select all
any{genres; "Yes Genres"}{"No Genres"}
This code works due to the Unwind-on-Undefined Behaviour. Checking for null won't work, because the {genres} does not yield a null value when undefined, but throws an exception yielding no value at all.
@see viewtopic.php?f=5&t=1895
Re: if genres undefined then...
well he was asking for it do nothing if genre found, so this will not do
the only way I can make it "do nothing" it this:
but what he really wants (I think) is this:
or is it this way ?

Code: Select all
any{genres; "Yes Genres"}{"No Genres"}
Code: Select all
{ (any{genres; 'Yes Genres'}{'No Genres'}).replace(/Yes Genres/,'') }
Code: Select all
{any{genres; genres.take(1)}{'qwerty'}}
Code: Select all
{any{genres; 'movies'}{'qwerty'}}/{ny}
Re: if genres undefined then...
Why not just return an empty String?

Code: Select all
any{genres; ""}{"No Genres"}
Re: if genres undefined then...
well for a very good reason.... does NOT work 
ALWAYS output

Code: Select all
{any{genres; ""}{'qwerty'}}
qwerty
Re: if genres undefined then...
I see. I guess "" is also evaluates to Groovy Truth FALSE and so it moves on.
I guess it'll have to return at least a non-Empty String to work:

I guess it'll have to return at least a non-Empty String to work:
Code: Select all
any{genres; ' '}{'querty'}
-
- Power User
- Posts: 89
- Joined: 01 Feb 2014, 16:59
Re: if genres undefined then...
My 2 cents on the issue:
For months now, the check in my code for (no genre exists) has failed and caused an error - and I think this is the original poster's question:
I use:
but I now get
I have been unable to find any way around this.
The simplest (theoretical) answer is
but it doesn't work...
For months now, the check in my code for (no genre exists) has failed and caused an error - and I think this is the original poster's question:
Code: Select all
If a genre exists then
Show me nothing
Else
Show me 'qwerty'
Endif
Code: Select all
{((genres ?: ['GENRE']))}
Code: Select all
[Expression yields empty value: Binding "genres": undefined]
The simplest (theoretical) answer is
Code: Select all
{((genres ? "": ['qwerty']))} <--- show a blank if a genre exists, else show 'qwerty"