Page 1 of 1

if genres undefined then...

Posted: 20 Mar 2018, 15:46
by peymanch
hi
if genres is undefined then use ...
how to?

Re: if genres undefined then...

Posted: 20 Mar 2018, 17:41
by rednoah
e.g.

Code: Select all

any{genres}{'No Genres'}
@see viewtopic.php?f=5&t=1895

Re: if genres undefined then...

Posted: 21 Mar 2018, 10:43
by peymanch
thanks but i want if genres are defined then do nothing! else if genres are undefined write "qwerty"

Re: if genres undefined then...

Posted: 21 Mar 2018, 18:26
by peymanch
peymanch wrote: 21 Mar 2018, 10:43 thanks but i want if genres are defined then do nothing! else if genres are undefined write "qwerty"
Please answer

Re: if genres undefined then...

Posted: 22 Mar 2018, 09:38
by ChefGregS
He answered you...did you not see it?

any{genres}{'No Genres'}

simply change No Genres to whatever you want..

any{genres}{'qwerty'}

Re: if genres undefined then...

Posted: 22 Mar 2018, 14:34
by peymanch
ChefGregS wrote: 22 Mar 2018, 09:38 He answered you...did you not see it?

any{genres}{'No Genres'}

simply change No Genres to whatever you want..

any{genres}{'qwerty'}
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...

Posted: 22 Mar 2018, 21:30
by ChefGregS
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.

Code: Select all

M:/{vf == /2160p/ ? 'Movies 4K' : vf =~ /1080p|720p/ ? 'Movies HD' : 'Movies'}
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:/{genre == null ? "qwerty" : "Movies"}/

Re: if genres undefined then...

Posted: 23 Mar 2018, 06:21
by rednoah
You could do this:

Code: Select all

any{genres; "Yes Genres"}{"No Genres"}
:arrow: 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...

Posted: 23 Mar 2018, 13:11
by ChefGregS
rednoah wrote: 23 Mar 2018, 06:21 You could do this:

Code: Select all

any{genres; "Yes Genres"}{"No Genres"}
:arrow: 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
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! LOL

Re: if genres undefined then...

Posted: 23 Mar 2018, 18:04
by kim
well he was asking for it do nothing if genre found, so this will not do ;)

Code: Select all

any{genres; "Yes Genres"}{"No Genres"}
the only way I can make it "do nothing" it this:

Code: Select all

{ (any{genres; 'Yes Genres'}{'No Genres'}).replace(/Yes Genres/,'') }
but what he really wants (I think) is this:

Code: Select all

{any{genres; genres.take(1)}{'qwerty'}}
or is it this way ?

Code: Select all

{any{genres; 'movies'}{'qwerty'}}/{ny}

Re: if genres undefined then...

Posted: 23 Mar 2018, 23:01
by rednoah
Why not just return an empty String? :lol:

Code: Select all

any{genres; ""}{"No Genres"}

Re: if genres undefined then...

Posted: 24 Mar 2018, 02:52
by kim
well for a very good reason.... does NOT work ;)

Code: Select all

{any{genres; ""}{'qwerty'}}
ALWAYS output
qwerty

Re: if genres undefined then...

Posted: 24 Mar 2018, 11:50
by rednoah
I see. I guess "" is also evaluates to Groovy Truth FALSE and so it moves on. :lol:

I guess it'll have to return at least a non-Empty String to work:

Code: Select all

any{genres; ' '}{'querty'}

Re: if genres undefined then...

Posted: 31 Mar 2018, 15:51
by DavidRTurner
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:

Code: Select all

If a genre exists then
   Show me nothing
Else
   Show me 'qwerty'
Endif
I use:

Code: Select all

{((genres ?: ['GENRE']))}
but I now get

Code: Select all

[Expression yields empty value: Binding "genres": undefined]
I have been unable to find any way around this.

The simplest (theoretical) answer is

Code: Select all

{((genres ? "": ['qwerty']))}   <--- show a blank if a genre exists, else show 'qwerty"
but it doesn't work...