INTERACT FORUM

Please login or register.

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

Author Topic: Expressions - a few more questions...  (Read 4236 times)

EpF

  • Citizen of the Universe
  • *****
  • Posts: 649
Expressions - a few more questions...
« on: April 19, 2005, 12:47:39 am »

1
How do I handle spaces in expressions:

If(IsEqual([Artist], Abba, 1), Too embarrassing, [Artist]) doesn't work if you have:

If(IsEqual([Artist], William Shatner, 1), Too embarrassing, [Artist])...

2
Quote
The JRiver Media Core database engine supports Excel-style functions for use in view schemes, searches, and displayed columns.

What is meant by 'searches' - expressions don't work in the search bar...?

3
Is it possible to use lists of values in expressions?

If(IsEqual([Artist], Abba,William Shatner, 1), Too embarrassing, [Artist])

and if not, then consider it a feature request!

I seem to remember getting the impression that the basis for the expression evaluator is a programming language, which I know nothing about; if this is the case, I'd appreciate someone telling me what language, so I could look into it...

Listening to 'Rising Sun' by Susumu Yokota, from 'Laputa' (2004)

EpF

  • Citizen of the Universe
  • *****
  • Posts: 649
Re: Expressions - a few more questions...
« Reply #1 on: April 19, 2005, 08:12:55 pm »

Anybody?

StiX

  • Regular Member
  • Recent member
  • *
  • Posts: 23
  • i really have nothing more to say...
Total Expressions Review
« Reply #2 on: April 19, 2005, 11:14:27 pm »

There's really currently nothing else, except what is written in documentation.

Will make a basic classification of all functions.

Condition
1. If(True/False, Then, Else)
    FormatBoolean(True/False, Then, Else) = If()

Validation (output: Boolean value)
2. IsEqual()
    IsEmpty([Field]) = IsEqual([Field],)
3. IsRange()
4. IsMissing()

Calculated Fields as "Functions" (Functions which outputs same data as regular Calculated [Fields])
    AlbumArtist() = [Album Artist (auto)]
    AlbumType() = [Album Type]
    FileName() = [Filename (name)]
    FilePath() = [Filename (path)]
    FileVolume() = [Volume Name]
    Size() = [File Size]
    IsRemovable() = [Removable]

Strings
5. Clean()  Inconsistently working function:
          Removes following Leading/Trailing Characters: Spaces; -
          Removes following Character Groups: []; ()
          Doesn't remove following characters/groups: SingleBracket; |; /(/); {}
          Will Clean Trailing brackets /(/) if there's at least one space character before the closing function bracket.
                 Ex.    :  Will Remove:        Clean(/([Field]/) )
                 Ex.2  :  Will Not Remove:  Clean(/([Field]/))
          Doesn't remove Trailing Space when a Closing square bracket is after the Function's Bracket.
                 Ex.   :  [Clean(Text   )]Text
                 Ex.2 :  Clean(Text   )Text
6. FixCase()
7. FormatDate()
8. Mid()


As you can see, the whole "language" consists only from 8 functions, regardless of documentation complications. Other "functions" are simply duplicate each other or are alternatives to regular already accessible Calculated Factory Default [Fields], which in fact, can't be deleted, in spite of there are already equivalent functions. And, there's really nothing more to say.

But, even with this overlimited amount of functions it is possible to build heavily complex expressions by having hundreds of nested conditions thanks to the if() conditional statement. Of course writing expressions could be simplified by adding at least possibility to expand the single-line expression to a multi-line script. But, currently JRiver just don't have time to work on a parser.




Now, answers

Quote
1. How do I handle spaces in expressions
Currently this behaviour is not documented. Peoples can recognize the behaviour only after experimenting. So, the rule:
You can add Leading space characters of any quantity in any Function after commas, as they're all removed at Expression evaluation.
You can add Leading space characters of any quantity in some cases after opening parenthesis, as they're all removed at Expression evaluation.
You should not add Trailing space characters before closing parenthesis, commas, as they're actually considered as spaces.
Examples by following the rule:
Code: [Select]
IsEqual(  [Artist],   Abba) = TRUE
IsEqual([Artist],Abba) = TRUE
IsEqual([Artist],         Abba) = TRUE
IsEqual([Artist] ,         Abba) = FALSE
IsEqual([Artist],Abba ) = FALSE
IsEqual([Artist],  Abba) = TRUE

Perhaps this was decided for the sake of readability, even if this makes some inevitable inconveniences.

Currently there is no way to enclose strings with single (') or double (") quotes


Quote
2. What is meant by 'searches' - expressions don't work in the search bar...?
They're, actually, work. But they're totally different from those, which are used in View Schemes and "Rename Files from Properties" dialog.

The similarity with Excel, is that the Expression should start with equality character "=". But there also should be added an opening bracket.

The Expression consist from 2 sides (Left and Right) and should have a regular mathematic expression in form
Code: [Select]
[=Function(PARAM1,PARAM2)]=Function(PARAM1,PARAM2)You can use any Functions or Fields on neither sides. The primary difference from Expressions in other parts of the Software is that you can build and compare two Expressions to receive a True/False result. There can be only a Boolean result after evaluating this expression:
     1, when Left Side = Right Side
     0,  when Left Side <> Right Side
MC in ultra speed will calculate the expression for each DB Entry (for each file in your Library), and will show those files, for which the calculation results in "True" (1) value.


The SearchBar-Expression is a kind of conditional statement. To make it clear, I will compare this behaviour to regular If() function:
Code: [Select]
If( [Function(PARAM1,PARAM2)]=Function(PARAM1,PARAM2), Show DB Entry in List View, Don't Show)
Now some examples:
The 1st meaningful expression I saw on INTERACT. Following will show All Missing Files:
Code: [Select]
[=IsMissing([FileName])]=1
To show only songs of artists, names of which starts from A to C:
Code: [Select]
[=IsRange([Artist], a-c)]=1
To show only songs of artists, names of which starts from D, J-K, Z:
Code: [Select]
[=IsRange([Artist], d-d)]=1 or [=IsRange([Artist], j-k)]=1 or [=IsRange([Artist], z-z)]=1
     OR
[=If(IsRange([Artist], d-d),1,  If(IsRange([Artist], j-k),1,  If(IsRange([Artist], z-z),1, ) ) ]=1


Notice that you can't use "True" or "False" keywords on neither side.

Until now I didn't tried to use Expressions on both sides of Boolean Expression, and I thought that it is certainly can be written on both sides. But, after many experimentations, I have come to conclusion, that Currently Expression can be only on Left Side. So, forget about expressions on both sides of Boolean Expression
Any of following SearchBar-Expressions are invalid:
Code: [Select]
1=[=IsRange([Artist], a-c)]
[1=[=IsRange([Artist], a-c)]
[=1=[=IsRange([Artist], a-c)]
[=IsRange([Artist], a-c)=IsRange([Artist], a-c)]
[=Function(PARAM1,PARAM2)]=Function(PARAM1,PARAM2)


Quote
3. Is it possible to use lists of values in expressions?
There are no Parsing functions in the language yet. You can't create arrays. There are even no Variable support! You really have only the If().

In your example the problem can be solved in following form (remove @CRLF's):
Code: [Select]
If(
      IsEqual([Artist],                 Abba),
      ,Too embarrassing
      ,If(
           IsEqual([Artist],            William Shatner),
           ,Too embarrassing
           ,If(
                 IsEqual([Artist],      William),
                ,Too embarrassing
                ,[Artist]
            )
      )
)
As you can see, because of lack of functions, this simple Expression can be a nightmare for 500 artists. But if you would need to create such an expression for 500 artists, then better to develop such an expression with another Scripting/Macros language, which contain string-related functions to parse a character-delimited string and concatenate an MC-Valid DBExpression (Ex. with VBScript, VBA, WinBatch, Macro ToolsWorks, etc.).

Alternatively you can create a [New Field], call it [Too embarrassing], put any characters to this field for all songs of each artist, then create a single-line expression:
Code: [Select]
If( IsEqual([Too embarassing],), [Artist],Too embarrassing)
The Editable Expressions idea for MC Database is currently is still in Draft state. The "Language" wasn't designed carefully. Hopefully it will be totally rewritten from ground up with all above considerations.
Logged

EpF

  • Citizen of the Universe
  • *****
  • Posts: 649
Re: Total Expressions Review
« Reply #3 on: April 20, 2005, 12:01:00 am »

 :o  Wow!  That's amazing StiX - you sure do know your stuff!  Thanks a million for that; it's a huge help.

One thing; when I tried this

Code: [Select]
IsEqual(  [Artist],   Abba) = TRUE

I got a FALSE answer - can that be right?

Alternatively you can create a [New Field], call it [Too embarrassing], put any characters to this field for all songs of each artist, then create a single-line expression:

If( IsEqual([Too embarassing],), [Artist],Too embarrassing)

I had to laugh at this - I only used that original example cause it's the J River classic, but the point is well made..

Thanks again
 ;D

StiX

  • Regular Member
  • Recent member
  • *
  • Posts: 23
  • i really have nothing more to say...
Re: Total Expressions Review
« Reply #4 on: April 20, 2005, 08:36:27 am »

:o  Wow!  That's amazing StiX - you sure do know your stuff!  Thanks a million for that; it's a huge help.

One thing; when I tried thisI got a FALSE answer - can that be right?

I had to laugh at this - I only used that original example cause it's the J River classic, but the point is well made..

Thanks again
 ;D
In some case I got a TRUE result. But forget it.

Here is an addition to my Review:
You cannot add leading spaces after opening parenthesis.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42373
  • Shoes gone again!
Re: Expressions - a few more questions...
« Reply #5 on: April 20, 2005, 09:27:29 am »

Thanks StiX -- you really know your stuff.

White space always has meaning in MC expressions.  The only exception is immediately after a comma in a function. (which was done for readability reasons)

The alternative to this is to have meaningless white space like some programming languages.  The downside is that this requires all strings to be put in quotes, and makes concatenation more ambiguous.
Logged
Matt Ashland, JRiver Media Center

StiX

  • Regular Member
  • Recent member
  • *
  • Posts: 23
  • i really have nothing more to say...
Re: Expressions - a few more questions...
« Reply #6 on: April 20, 2005, 05:51:36 pm »

 :) Thanks Matt, EpF. It was my pleasure to analyze this.

I don't have nothing against spaces after commas, I just think that you had to describe this very important behaviour in DBExpressions.htm in Notes Section (that you already done in April-20 Documentation) and add to the list of special characters, the space word.
Quote
To use a special character (bracket, parenthesis, space) as regular text in a function, place a / before it.
so that there will be never again a question about this  ;)

Additionally to the new &DataType and formatting Functions it would be not an excess to add an IsContain() function. I hope it will be available in next beta.
Logged

hit_ny

  • Citizen of the Universe
  • *****
  • Posts: 3310
  • nothing more to say...
Re: Expressions - a few more questions...
« Reply #7 on: April 21, 2005, 02:12:22 am »

Is it possible to get summaries in a column view scheme ?

eg. how many albums are there by genre.

genre 1 (total)
genre 2 (total)
....
genre n (total)

i(in addition) to the (Total) at the top of the column.

i know i can manually check by clicking each genre but was hoping to get an idea (at a glance) of the top 5 for example

a summary by group can be useful in many situations.
Logged
Pages: [1]   Go Up