INTERACT FORUM

More => Old Versions => JRiver Media Center 18 for Windows => Topic started by: Klaus_K on November 08, 2012, 05:19:01 am

Title: Problems using clean() function
Post by: Klaus_K on November 08, 2012, 05:19:01 am
Hi,

i was playinga round with the clean function, because I thought I could use it for my classical collection.

I have custom tags for [work], [work_key], [work_opus] and [work_opno]

At the moment I just combine them in a custom expression using the build list function, so they end up like:

Piano sonata no.3 C major op.2 Nr.3

What I thought I could achieve was introducing a comma between [work_key] and [work_opus] so that it looks like

Piano sonata no.3 C major, op.2 Nr.3

I now built an expression "[work], [work_key], [work_opus] [work_opno]" and used the clean function on it

the result is that I see the comma, even if the [work_opus] and the [work_opno] fields are not filled.

When I replace the comma by a hyphen, everything works out fine.

In the wiki it says:

Quote
Imagine the template without the Clean() function around it. [Artist] - [Album] /([Genre]/)
If used as an expression, this string, quite predictably, will return things such as: "AC/DC - Back In Black (Rock)", but, what if one or more of the specified fields contains no data? The result would be rather untidy, such as: "- Back In Black ()" if there were no [artist] or [genre] data.
Wrap the template inside the Clean() function to tidy these cases up, so, "- Back In Black ()" would become "Back In Black"

there's no mention about characters that can't be used.

What am I doing wrong? I also tried to escape the comma in the expression but without success. When I try to put [work_opus] in escaped brackets like in the example from the wiki it also works, but not with any other character I've tried.

Thanks for your help
Klaus




Title: Re: Problems using clean() function
Post by: MrC on November 08, 2012, 12:04:42 pm
I'm not sure I'm entirely following your goal, but if I am, use the more general:

listbuild(1, /,/ ,
   listbuild(1, / , [work], [work_key]),
   listbuild(1, / , [work_opus], [work_opno])
)
Title: Re: Problems using clean() function
Post by: Klaus_K on November 08, 2012, 01:22:23 pm
Hi MrC

thanks for the advice. It didn't come to me that I could nest two listbuild commands.

But still: why does is not work with clean()? It says you can clean a template. What if the template contains commas instead of hyphens?

clean([work] [work_key], [work_opus] [work_opno]) doesn't work
(i.e. it still shows the commas when [work_opus] and [work_opno] is empty,
whereas
clean([work] [work_key] - [work_opus] [work_opno]) works.

Regards
Klaus
Title: Re: Problems using clean() function
Post by: glynor on November 08, 2012, 01:40:16 pm
I don't think Clean() removes commas.  I'm not sure what you're trying to accomplish with the Clean() function.

EDIT:  Ahh, now I see.  Yes, that's the problem.  Clean() is a relatively simplistic text find-and-replace function, I think.  It doesn't remove commas because commas are likely to be a valid part of a field.  For example:

[Artist] = Amos, Tori
or
[Artist] = Beatles, The
or even
[Album] = Lifted or The Story is in the Soil, Keep Your Ear to the Ground

If it stripped out commas, it would cause havoc for all of those valid fields.

If you want to build a delimited string, the ListBuild() function is what you want, because it knows to omit empty fields.

Title: Re: Problems using clean() function
Post by: MrC on November 08, 2012, 02:14:00 pm
Maybe we can get the inside scoop from Matt as to the exact behavior of Clean() in the default mode 0.  I'll document it.
Title: Re: Problems using clean() function
Post by: glynor on November 08, 2012, 02:34:00 pm
Maybe we can get the inside scoop from Matt as to the exact behavior of Clean() in the default mode 0.  I'll document it.

Yeah.  Zero mode is weird.

I only ever use Clean() to:

1. Generate filename-safe versions of things (mode three).
2. Remove leading and trailing spaces from tags.