INTERACT FORUM

Please login or register.

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

Author Topic: Expression's Man Pages? or is there a good reference for syntax ?  (Read 1085 times)

666JTK666

  • Junior Woodchuck
  • **
  • Posts: 75

I am recovering from a bad data loss of my library including loss of all my expressions that I created years ago. So I am having to rebuild pretty much from scratch, it sux but is what it is.
So I am looking for any reference info on how to build expressions. I don't really want to just beg for help for every little thing I want to do that does not feel right to me.

As a side question what are you good folks doing to safeguard your expressions and your media library? The problems associated with making an on going backup of an ever expanding and changing data set are daunting.
Logged

Yaobing

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10926
  • Dogs of the world unite!
Logged
Yaobing Deng, JRiver Media Center

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Expression's Man Pages? or is there a good reference for syntax ?
« Reply #2 on: August 08, 2019, 04:17:13 pm »

I'm exporting everything complex to txt files. So I can just copy paste singe expressions back if I mess something up. Of course library backups will save everything also if everything has been lost or don't quite know how much of mess I have been creating
Logged

666JTK666

  • Junior Woodchuck
  • **
  • Posts: 75
Re: Expression's Man Pages? or is there a good reference for syntax ?
« Reply #3 on: August 08, 2019, 05:03:27 pm »

Ok I am going through the wiki and working on my expression it's not going so well I am missing something basic I think.

I have a calculated field that I call Fancy Book Title.
what I am trying to do is have it evaluate the data in my tags to output a variable book name.

here is the expression.
Ifelse(isempty([Book Series Title], [Book Title],[Book Title] - [Book Series Title] Book [Book Series Volume]))

If someone would hit me with a clue by 4 I would appreciate it.


Edit:
this expression seems to work.
If(isempty([Book Series Title]), [Book Title],[Book Title] - [Book Series Title] Book [Book Series Volume])

not sure why I need the first comma after the isempty )
Logged

666JTK666

  • Junior Woodchuck
  • **
  • Posts: 75
Re: Expression's Man Pages? or is there a good reference for syntax ?
« Reply #4 on: August 08, 2019, 05:35:17 pm »

ok , So [Fancy Book Title] should either be just [Book Title] if there is no [Book Series Title] if there is a [Book Series Title] then [Fancy Book Title] should be "[Book Title] - [Book Series Title] Book [Book Series Vol.]"

example
[Book Title] = nifty book
[Book Series Title] = "" blank no data
[Book Series Vol] = "" blank no data
wanted output is: nifty book

[Book Title] = nifty book
[Book Series Title] = Fab book Series
[Book Series Vol] = 1
wanted output is: nifty book - Fab book Series Book 1



Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Expression's Man Pages? or is there a good reference for syntax ?
« Reply #5 on: August 08, 2019, 06:04:07 pm »

As a side question what are you good folks doing to safeguard your expressions and your media library? The problems associated with making an on going backup of an ever expanding and changing data set are daunting.

My system seems quite safe and I have moved my library between at least 5 versions of MC (manually) and copied it to at least 4 other systems successfully.

1.  MC has a Library backup and restore function.  You can use Backup any time you want.  Backup is also automatically run for you every few days.  After about a month, it trims off most of the backups and saves a monthly.  So you will end up with around 10 to 15 backups in a month, and then monthly backups forever.  This happens by default without you doing anything extra.  Backups are stored in the location specified in this option:

Tools > Options > File Location > Program Files > Library Backups

You can leave this as is, or change to the location of your choice.

2.  I have backup software running on my MC machine that takes incremental backups once an hour to an external drive.  This has worked well so far.  However...
3.  I manually run full backups of my important files (Documents, Music folder, etc) using a script.  I run this once a week or once every few weeks.  It is also incremental as it uses rsync.  I only save one copy of this, but it goes to a second external drive.  Extra insurance.

You could substitute some or all of my setup with "cloud" backup also.  Or drives that you rotate off site to some other location for safe keeping.

4.  Restoring an MC Library is super duper easy if you have the backup ZIP file.  File > Library > Restore Library .  These restores contain ALL expressions, all library fields, all views, all metadata, etc.  There are a couple of minor things that are not saved, but it's pretty darned complete.

5.  I used to save expressions to text files also, but that got to be a pain and I no longer do it.

Brian.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Expression's Man Pages? or is there a good reference for syntax ?
« Reply #6 on: August 08, 2019, 06:18:22 pm »

ok , So [Fancy Book Title] should either be just [Book Title] if there is no [Book Series Title] if there is a [Book Series Title] then [Fancy Book Title] should be "[Book Title] - [Book Series Title] Book [Book Series Vol.]"

Pseudo-code:

if ([Book Series Title] is not empty) then
    print "[Book Title] - [Book Series Title] Book [Book Series Vol.]"
else
    print "[Book Title]"
end if

Translated to MC:

ifelse(!IsEmpty([Book Series Title]),
    [Book Title] - [Book Series Title] Book [Book Series Vol.],
    [Book Title]
)

Stuffed altogether in one line for easier cut and paste:
Code: [Select]
ifelse(!IsEmpty([Book Series Title]),[Book Title] - [Book Series Title] Book [Book Series Vol.],[Book Title])
This is completely untested so I might have a syntax error, but I tried to be pretty careful while writing these.  I hope this gets you pushed in the right direction.  I think what you missed with the ifelse() function is that there are 3 clauses: 
1.  Conditional to test on
2.  The thing to show if true
3.  The thing to show if false

That's why you need two commas.

Good luck.

Brian.
Logged

BryanC

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2663
Re: Expression's Man Pages? or is there a good reference for syntax ?
« Reply #7 on: August 09, 2019, 07:35:31 am »

Pseudo-code:

if ([Book Series Title] is not empty) then
    print "[Book Title] - [Book Series Title] Book [Book Series Vol.]"
else
    print "[Book Title]"
end if

Translated to MC:

ifelse(!IsEmpty([Book Series Title]),
    [Book Title] - [Book Series Title] Book [Book Series Vol.],
    [Book Title]
)

Stuffed altogether in one line for easier cut and paste:
Code: [Select]
ifelse(!IsEmpty([Book Series Title]),[Book Title] - [Book Series Title] Book [Book Series Vol.],[Book Title])
This is completely untested so I might have a syntax error, but I tried to be pretty careful while writing these.  I hope this gets you pushed in the right direction.  I think what you missed with the ifelse() function is that there are 3 clauses: 
1.  Conditional to test on
2.  The thing to show if true
3.  The thing to show if false

That's why you need two commas.

Good luck.

Brian.

You'll want to use plain if here (not if-else):

Code: [Select]
if(!IsEmpty([Book Series Title]),[Book Title] - [Book Series Title] Book [Book Series Vol.],[Book Title])
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Expression's Man Pages? or is there a good reference for syntax ?
« Reply #8 on: August 09, 2019, 08:29:52 am »

Thank you for catching my mistake BryanC!

Brian
Logged
Pages: [1]   Go Up