INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  

Poll

Do you find it useful?

Yes
No
Looks too complicated

Pages: [1]   Go Down

Author Topic: For Expressions enthusiasts - custom Pane  (Read 4411 times)

gk666999

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 68
For Expressions enthusiasts - custom Pane
« on: January 10, 2006, 10:50:02 am »

This expression is used to add pane called "Import History" as shown below. I find this way of grouping convinient to use in Windows explorer (View->Details, Arrange Icons by->Modified, Show in Groups), so I created something similar in MC.


UPDATE: see my "This one works ?" post below




It uses pre-defined custom calculated Library field [Imported (days ago)] which has to be created in advance as follows: go to Tools->Options->Library->Add and name the field [Imported (days ago)] (without the brackets). Activate the Calculated Data template field and copy'n'paste

FormatNumber(FormatDate([Date Imported,0], elapsed),0)

Press OK, press OK again to exit the Options screen. Now go to Audio view with Panes, enter in the Edit View Scheme screen and add new view item (use 'Advanced Expression' when asked), name it "Import History" and copy'n'paste the below expression in the expression text box.

If(IsRange([Imported (days ago)], 0-7),1. Last week,If(IsRange([Imported (days ago)], 8-30),2. Last month,If(IsRange([Imported (days ago)], 31-90),3. Last 3 months,If(IsRange([Imported (days ago)], 91-182),4. Last 6 months,If(IsRange([Imported (days ago)], 183-365),5. Last year,6. Older than a year))))

Optional step - move it up the list of existing panes. Press OK, press OK second time to exit View Scheme window. You should now have a new pane.


P.S. Since we don't have any snow here, in Minnesota (doh! :o), I obviosly have too much time on hand to fool around with expressions insted of loadin up my iPod and going skiing.




 [img width= height=]http://www.moscowonthehill.com/screenshot.jpg[/img]
Logged

hit_ny

  • Citizen of the Universe
  • *****
  • Posts: 3310
  • nothing more to say...
Re: For Expressions enthusiasts - custom Pane
« Reply #1 on: January 10, 2006, 11:03:57 am »

Hah, you just described my Import View Scheme.

The interesting part is that you have used Expressions to achieve this.. i'm wondering if i can use this instead to make my view scheme more responsive .

As i currently have it, its a smartlist group with each item described as a smartlist. Then the viewscheme just points to the node of the group to get the items for the first pane (Import History). It's slow to display as MC has to calculate the result of each smartlist sequentially before displaying the view sheme.
Logged

sbsp2

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 402
Re: For Expressions enthusiasts - custom Pane
« Reply #2 on: January 10, 2006, 11:14:25 am »

Doesn't appear to work in 11.1.96 as all I get is '6. Older than a year' for all my MP3s.  I've imported MP3s today, yesterday and lots over the last 6 mos.  Weird.

Update: All my Imported (days ago) values are -263611 and smaller.  MC sounds broken (I guess).
Logged

gk666999

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 68
Re: For Expressions enthusiasts - custom Pane
« Reply #3 on: January 10, 2006, 12:00:16 pm »

Hmm, it happened to me too, once. I could not reproduce it again, but just in case, I changed the Imported (days ago). The expression at the top is the updated one now. I put zero, although it is the default value.
Don't forget to exit and reopen MC after changes, since some calculated fields do not update otherwise.
Logged

sbsp2

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 402
Re: For Expressions enthusiasts - custom Pane
« Reply #4 on: January 10, 2006, 12:12:25 pm »

Hmm, it happened to me too, once. I could not reproduce it again, but just in case, I changed the Imported (days ago). The expression at the top is the updated one now. I put zero, although it is the default value.
Don't forget to exit and reopen MC after changes, since some calculated fields do not update otherwise.

Yeah, I tried a few things including the ',0' addition and nothing works.  I even changed it to just [Date Imported] for the calculated value and it displayed the same (bad) values in the display column that I added (for testing).
Logged

gk666999

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 68
Re: For Expressions enthusiasts - custom Pane
« Reply #5 on: January 10, 2006, 12:38:26 pm »

If it helps - here is my screenshot of the View Item and Panes.  And one more thing - I only tested this on audio.






Also, I am sure you're aware of this, but be careful with spaces and parenthesises, I've learned my lesson this morning; one extra space can render whole thing useless.

Question: do you use [Date Imported] in smartlists, and if yes - are these working OK?
Logged

sbsp2

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 402
Re: For Expressions enthusiasts - custom Pane
« Reply #6 on: January 10, 2006, 12:59:59 pm »

I missed the ,0 you added to [Date Imported].  Now it kind of works.

But, there's still a bug somewhere as tracks imported yesterday show 28 days ago.  Others imported 2 yrs ago show 1 day ago.

It's all ugly.
Logged

gk666999

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 68
Re: For Expressions enthusiasts - custom Pane
« Reply #7 on: January 10, 2006, 01:22:39 pm »

Did I understand correctly: tracks displaying the right Date Imported in raw format don't display it correctly in calculated form?

I have noticed that grouping is not working right.

I will continue to play with it and post later 2night...
Logged

gk666999

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 68
Re: For Expressions enthusiasts - custom Pane
« Reply #8 on: January 10, 2006, 01:31:06 pm »


i'm wondering if i can use this instead to make my view scheme more responsive .


Did it work?
Logged

EpF

  • Citizen of the Universe
  • *****
  • Posts: 649
Re: For Expressions enthusiasts - custom Pane
« Reply #9 on: January 10, 2006, 04:08:11 pm »

Would be great, but it doesn't work in 11.1 at the moment; I've been trying to get something like it to work for 2 days - nada!

hit_ny

  • Citizen of the Universe
  • *****
  • Posts: 3310
  • nothing more to say...
Re: For Expressions enthusiasts - custom Pane
« Reply #10 on: January 11, 2006, 01:45:09 am »

Did it work?
I'm still on 11.0

Don't think i can use expressions in Calculated fields.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: For Expressions enthusiasts - custom Pane
« Reply #11 on: January 11, 2006, 03:07:10 am »

I missed the ,0 you added to [Date Imported].  Now it kind of works.

But, there's still a bug somewhere as tracks imported yesterday show 28 days ago.  Others imported 2 yrs ago show 1 day ago.

It's all ugly.
the number has been forced here, if you look at the default "elapsed" output, you will see that up to 3 or 4 days, elapsed is output in hours, so it's not 28 days ago, it's 28 hours ago, next it steps up to days ago, and then steps into years.
the described setup will only work as expected with "days ago" values.

gk666999

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 68
Re: For Expressions enthusiasts - custom Pane
« Reply #12 on: January 11, 2006, 03:49:08 pm »

the number has been forced here, if you look at the default "elapsed" output, you will see that up to 3 or 4 days, elapsed is output in hours, so it's not 28 days ago, it's 28 hours ago, next it steps up to days ago, and then steps into years.
the described setup will only work as expected with "days ago" values.


I am kind of stuck at trying to format time in one consistent measure, be that seconds, minutes, hours or days. Is there a way to do that? I know there is possibility to format duration. . .
Logged

gk666999

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 68
This one works ?
« Reply #13 on: January 12, 2006, 09:20:54 am »

I found the way around the problem with MC's way to format date in hours and days with this string should take care of files with 'xx.x hours' in output of elapsed time of import:

If(IsEqual(Mid(FormatDate([Date Imported,0],elapsed),5,5),hours,1),1. Last 2 days

(not completely sure, but it seems that after 48 hours the output comes as 'days'
This string gets the Date Imported in elapsed format and reads five characters of it, starting from the fifth. If it says "hours", than this file belongs to "1. Last 2 days" category. You will see below in the code that I added similar string for files with hh:mm:ss in the elapsed date of import - it reads third character, and if there is ":", than it belong to "0. Today" category.


So, my pane 'Import History' looks like that now:



Go to Audio view with Panes, enter the Edit View Scheme screen and add new view item (use 'Advanced Expression' when asked), name it "Import History" and copy'n'paste the below expression in the text box.

and this is the code:

If(IsEqual(FormatDate([Date Imported,0],elapsed),1d,4),0. Today,If(IsEqual(Mid(FormatDate([Date Imported,0],elapsed),2,1),:,1),0. Today,If(IsEqual(Mid(FormatDate([Date Imported,0],elapsed),5,5),hours,1),1. Last 2 days,If(IsEqual(FormatDate([Date Imported,0],elapsed), 7d, 4),2. Last Week,If(IsEqual(FormatDate([Date Imported,0],elapsed), 31d, 4),3. Older than one week,If(IsEqual(FormatDate([Date Imported,0],elapsed), 184d, 4),4. Older than one month,If(IsEqual(FormatDate([Date Imported,0],elapsed), 365d, 4),5. Older than half a year,6. Older than year)))))))

I really hope it'll work with others too. Let me know, I would like to clean up thist thread after we done here.


P.S. As you can see on the picture, I got the 'Imported (ago)' working correctly as well, though coud not sort it correctly, because it sorts as numeric values, so 3 hours will come next to 2 days. But this field is not needed now; I don't use it in 'Import History' pane. There is a code for this one:

If(IsEqual(Mid(FormatDate([Date Imported,0],elapsed),5,5),hours,1),Mid(FormatDate([Date Imported,0],elapsed),0,2) hours,If(IsEqual(Mid(FormatDate([Date Imported,0], elapsed),2,1),:,1),Mid(FormatDate([Date Imported,0],elapsed),0,2) hours,FormatNumber(FormatDate([Date Imported,0],elapsed),0) days))
Logged

sbsp2

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 402
Re: For Expressions enthusiasts - custom Pane
« Reply #14 on: January 12, 2006, 09:49:43 am »

Would be so much simplier if they'd just give you a formatdate() option like ElapsedDays and not have to kludge it all up so much.
Logged

gk666999

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 68
Re: For Expressions enthusiasts - custom Pane
« Reply #15 on: January 12, 2006, 09:55:37 am »

It used to be in minutes, remember the magic 1440 number?  ::)
Logged

EpF

  • Citizen of the Universe
  • *****
  • Posts: 649
Re: This one works ?
« Reply #16 on: January 12, 2006, 09:59:02 am »

I found the way around the problem...

and this is the code:

If(IsEqual(FormatDate([Date Imported,0],elapsed),1d,4),0. Today...
I just tried this, and it doesn't work because the part in bold returns this day one year ago, as well as today.

I've been working on this too, and haven't found a way around it (and don't think there is one, atm). If J River could set it up so that there was a way to get 'elapsed' in some raw format, rather than preformatted, it would be possible to do what we want to do.

The [Date Imported,0] format is basically the same as Excel's 1900 system (no. of days since 1900), as far as I can tell. Excel has a 'TODAY' function, which returns the current date - wouldn't it be cool if 'Today' and Arithmetic operators worked in MC, like in Excel? The two together would solve this problem, and Arithmetic functions would be great in other expressions too.

gk666999

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 68
Re: For Expressions enthusiasts - custom Pane
« Reply #17 on: January 12, 2006, 10:05:01 am »

Oops, I simply did not have that old of a music, since messing with beta versionf forced me to re-import library. This sounds a bit dissapointing, but not over just yet.
Logged
Pages: [1]   Go Up