INTERACT FORUM

Please login or register.

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

Author Topic: Thumbnail Text expression help  (Read 2241 times)

wig

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 750
Thumbnail Text expression help
« on: March 23, 2012, 09:15:05 am »

I'm using the following for thumbnail text in a view

if(isequal([Album Artist (auto)],Multiple Artists,8),,[Album Artist (auto)])

Two questions:

1) I originally tried to use an exact string of (Multiple Artists) as the comparison, but I couldn't properly escape the quotes. Here's what I thought would work.

if(isequal([Album Artist (auto)],/(Multiple Artists),1),,[Album Artist (auto)])

2) (Multiple Artists) albums still have two text lines, my expression just leaves the first line blank. Is there any way to remove the first line entirely?

Neither of these are show-stopping issues, but I have a curious mind  :)

Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Thumbnail Text expression help
« Reply #1 on: March 23, 2012, 11:11:14 am »

There was a missing / quote on the closing paren of (Multiple Artists) when comparing using mode 1.  In any case, use the default mode 0, and look for the exact string.  Here's the change, plus some:

  ifelse(!isequal([Album Artist (auto)], /(Multiple Artists/)), [Album Artist (auto)])

With the next release, you'll be able to write the expression:

   ifelse(
      !isequal([Album Artist (auto)], /(Multiple Artists/)),
          [Album Artist (auto)]
   )
Logged
The opinions I express represent my own folly.

wig

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 750
Re: Thumbnail Text expression help
« Reply #2 on: March 23, 2012, 11:27:34 am »

Thanks MrC, the idea of escaping a parentheses in the middle of a string just wasn't clicking.

The two expressions you listed are the same. Do you mean in the next release we'll be able to write the expressions with line breaks that will be ignored?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Thumbnail Text expression help
« Reply #3 on: March 23, 2012, 11:35:13 am »

The two expressions you listed are the same. Do you mean in the next release we'll be able to write the expressions with line breaks that will be ignored?

Yes, basically.
Logged
The opinions I express represent my own folly.

vagskal

  • Citizen of the Universe
  • *****
  • Posts: 1227
Re: Thumbnail Text expression help
« Reply #4 on: April 08, 2012, 05:21:31 am »

Any idea how to insert a line break in thumbnail text only if an expression produces a result?

[some expressions][New Line]
If(0,,)
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Thumbnail Text expression help
« Reply #5 on: April 08, 2012, 12:54:24 pm »

Any idea how to insert a line break in thumbnail text only if an expression produces a result?

It appears the thumbnail expression editor is using the actual newlines in the text entry area literally.  This produces peculiar results:

if(1,
T,
F
[Name])

I tried using a newline embedded in a Lyrics field, but the thumbnail text evaluator turns them into "..." (unprintable) chars.

So the rules seem to be:

  1) use exact newlines present in expression editor dialog
  2) replace non-printing characters in the output
Logged
The opinions I express represent my own folly.

vagskal

  • Citizen of the Universe
  • *****
  • Posts: 1227
Re: Thumbnail Text expression help
« Reply #6 on: April 08, 2012, 01:04:58 pm »

Thanks for the reply!

It appears the thumbnail expression editor is using the actual newlines in the text entry area literally.

Yes I noticed.

So the rules seem to be:

  1) use exact newlines present in expression editor dialog
  2) replace non-printing characters in the output


I do not understand. Are you saying this would work, i.e. not output a new line before T?

Replace(if(1,
T,
F
[Name]),...)

EDIT: Sorry I was not entirely clear. What I really meant was:

[some expressions that produce some text]If(0,[New Line]
[some text],)

i.e. no new line if the test in the if expression fails (0) but a new line if it succeeds (1).
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Thumbnail Text expression help
« Reply #7 on: April 08, 2012, 01:26:38 pm »

I don't think it will work as currently implemented.  To clarify what I'm perceiving to be what's happening...

All newlines entered into the thumbnail expression editor *will* be presented in the output.  MC appears to grab those newlines *before* the expression is evaluated, determines how many lines of output will be generated, and then always outputs that many lines.
Logged
The opinions I express represent my own folly.

vagskal

  • Citizen of the Universe
  • *****
  • Posts: 1227
Re: Thumbnail Text expression help
« Reply #8 on: April 08, 2012, 01:42:36 pm »

OK. Thanks for the clarification!

I have already asked/wished for a way of allowing line brakes in calculated fields so that they can serve as presets for the thumbnail text; the line brakes in a field would obviously have to be ignored in places where multiple lines are not supported.
Logged

rick.ca

  • Citizen of the Universe
  • *****
  • Posts: 3729
Re: Thumbnail Text expression help
« Reply #9 on: April 08, 2012, 07:10:29 pm »

Why don't you just use an appropriate conditional expression for each line. That might be awkward if there are many lines, but normally there are just few. For example, if the caption is normally three lines, but sometimes the value for the second is null, then...

{Expression for line 1}
If(IsEmpty({Expression for line 2}), {Expression for line 3}, {Expression for line 2})
If(IsEmpty({Expression for line 2}), , {Expression for line 3})

And I don't imagine it matters if {Expression for line 3} is null.
Logged

vagskal

  • Citizen of the Universe
  • *****
  • Posts: 1227
Re: Thumbnail Text expression help
« Reply #10 on: April 09, 2012, 12:33:56 am »

Well in my experience your suggested three line expressions would result in three lines always being shown, i.e. if the expression for line three results in null a new line (empty) will be inserted. I was trying to accomplish a more compact design of the thumbnail text with extra space between rows of thumbnails only when needed.
Logged

dtc

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3027
Re: Thumbnail Text expression help
« Reply #11 on: April 09, 2012, 06:16:21 pm »

If there were an ASCII(x) command in the expression language, then adding a new line to a display would be easy, or if there were just a keyword like CRLF that could be used to get a new dislay line it would be easy to put in a new line. That may already be available in regex in some way already, but I am not really familiar with regex. I believe it does deal with non visible ascii characters in octal and hex.

In album view, I would like to skip to a new line  when a field changes, like genre. In album view, I group by Genre, Artist, Album.  If in the thumbnail text there were an expression to compare the genre for the current album to the previous one, then a new CRLF could be easily added when the genre (or other field) changed. That would start a new line of thumbnails when the genre changes. Any thoughts if this is doable in the thumbnail expression?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Thumbnail Text expression help
« Reply #12 on: April 09, 2012, 06:31:06 pm »

That may already be available in regex in some way already, but I am not really familiar with regex. I believe it does deal with non visible ascii characters in octal and hex.

regex() matches input; it does not generate output.  Since there are no newline escape "codes" in the MC expression language (e.g. \n, \015) nor functions to output them, and because the thumbnail expression editor consumes and regurgitates newlines, they currently cannot be injected into the output programmatically.
Logged
The opinions I express represent my own folly.

rick.ca

  • Citizen of the Universe
  • *****
  • Posts: 3729
Re: Thumbnail Text expression help
« Reply #13 on: April 09, 2012, 07:43:33 pm »

Quote
If there were an ASCII(x) command in the expression language...

That would work, but since we already have some HTML text formatting tags, perhaps any additional commands should be in the form of HTML tags. That is, if it has any application elsewhere—I have my doubts a conditional line feed in thumbnail text is feasible...

All newlines entered into the thumbnail expression editor *will* be presented in the output.  MC appears to grab those newlines *before* the expression is evaluated, determines how many lines of output will be generated, and then always outputs that many lines.

This behaviour makes it easier for most users (i.e., just add a linefeed where one is needed). But I wonder if it might also be necessary to determine a fixed number of lines in advance—for the efficient rendering of the display.

Quote
In album view, I would like to skip to a new line  when a field changes, like genre.

I wish there were, but there's no grouping in an Album Thumbnail list style. The thumbnail text has no bearing on that.
Logged
Pages: [1]   Go Up