INTERACT FORUM

Please login or register.

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

Author Topic: Problems using clean() function  (Read 1469 times)

Klaus_K

  • Recent member
  • *
  • Posts: 35
Problems using clean() function
« 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




Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Problems using clean() function
« Reply #1 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])
)
Logged
The opinions I express represent my own folly.

Klaus_K

  • Recent member
  • *
  • Posts: 35
Re: Problems using clean() function
« Reply #2 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
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Problems using clean() function
« Reply #3 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.

Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Problems using clean() function
« Reply #4 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.
Logged
The opinions I express represent my own folly.

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Problems using clean() function
« Reply #5 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.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/
Pages: [1]   Go Up