INTERACT FORUM

Please login or register.

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

Author Topic: Is there a way to force completion of expressions before the next song starts?  (Read 233 times)

rbmjr

  • World Citizen
  • ***
  • Posts: 107

I am having a heck of a time updating the currently playing record with field updates that I want to make during playback. If I put the functions in the section if( IsPlaying(), expression goes here, ) they constantly calculate based upon (1) some scanning cycle (2) changes made to the queue during playback. I do not know how to get them to calculate only once.

If I put the functions in the If( IsPlaying(), , expression goes here ) then only the first variable I update gets updated and all the other fields end up in the next playing song.

I need to somehow either (1) stop the constant recalculation or (2) halt the execution until all the expressions have executed (something like a return code if( IsEqual( ReturnCode(), 1) then continue to the next song, else wait for the return code to change )

After playback expression doesn't seem to work either as the functions can't complete executing before the next song starts playing.

Help, thoughts, anything? Here is my code. I've verified that the calculations work. Just that they never end up in the right fields.

If( And( IsPlaying(), IsEqual( [GVWorkCounter], 0, 2) ),
>>>>
/# Save( Math( [GVWorkCounter] + 1 ), GVWorkCounter ) #/
Save( 1, GVWorkCounter )
SetField( WorkString, CTR: [GVWorkCounter] )
Save( [FileName], GVFileName )
Save( FormatDate( Now(), Date), GVNow )
/# SetField( WorkString, Load( GVNow ) ) #/
If( IsEmpty( [WorkList1x] ), Save( NO, GVWorkList2x ), Save( [WorkList1x] , GVWorkList2x ) )
/# SetField( WorkString, Load( GVNow) - Load( GVWorkList2x ) ) #/
If( IsEmpty( [SmartList] ), Save( NO, GVWorkList1x ), Save( [SmartList] , GVWorkList1x ) )
/# SetField( WorkString, Load( GVNow) - Load( GVWorkList2x ) - Load( GVWorkList1x ) ) #/
If( IsEmpty( [Last Played] ), Save( NO, GVLastPlayed ), Save( FormatDate( [Last Played,0], dd MM yyyy ), GVLastPlayed ) )
/# SetField( WorkString, Load( GVNow) - Load( GVWorkList2x ) - Load( GVWorkList1x ) - Load( GVLastPlayed) ) #/
If( IsEmpty( [WorkDate1x] ), Save( NO, GVWorkDate2x ), Save( FormatDate( ConvertDate( [WorkDate1x] ), dd MM yyyy ), GVWorkDate2x ) )
/# SetField( WorkString, Load( GVNow) - Load( GVWorkList2x ) - Load( GVWorkList1x ) - Load( GVLastPlayed ) - Load( GVWorkDate2x ) ) #/
If( IsEmpty( [Last Played] ), Save( NO, GVWorkDate1x ), Save( FormatDate( [Last Played,0], dd MM yyyy ), GVWorkDate1x ) )
/# SetField( WorkString, Load( GVNow) - Load( GVWorkList2x ) - Load( GVWorkList1x ) - Load( GVLastPlayed ) - Load( GVWorkDate2x ) - Load( GVWorkDate1x ) ) #/
/# Hold everything from here on #/
/# If( IsEmpty( [GVWorkList2x] ), SetField( WorkList2x, No ), SetField( WorkList2x, Load( GVWorkList2x ) ) ) #/
/# SetField( WorkString, Now: Load( GVNow) LP: Load( GVLastPlayed ) GVWD1: Load( GVWorkDate1x ) GVWD2: Load( GVWorkDate2x ) GVWL2: Load( GVWorkList2x ) WL2: [WorkList2x] GVWL1: Load( GVWorkList1x ) ) #/
/# If( IsEmpty( [SmartList] ), SetField( WorkList1x, NoWL1x ), SetField( WorkList1x, [SmartList] ) ) #/
/# SetField( WorkString, Now: Load( GVNow) LP: Load( GVLastPlayed ) GVWD1: Load( GVWorkDate1x ) GVWD2: Load( GVWorkDate2x ) GVWL2: Load( GVWorkList2x ) WL2: [WorkList2x] GVWL1: Load( GVWorkList1x ) WL1: [WorkList1x] ) #/
/# If( IsEmpty( [GVWorkDate2x] ), SetField( WorkDate2x, NoWD2x ), SetField( WorkDate2x, FormatDate( ConvertDate( Load( GVWorkDate2x) ), MM//dd//yyyy ) ) ) #/
/# SetField( WorkString, Now: Load( GVNow) LP: Load( GVLastPlayed ) GVWD1: Load( GVWorkDate1x ) GVWD2: Load( GVWorkDate2x ) WD2: [WorkDate2x] GVWL2: Load( GVWorkList2x ) WL2: [WorkList2x] GVWL1: Load( GVWorkList1x ) WL1: [WorkList1x] ) #/
/# If( IsEmpty( [Last Played] ), SetField( WorkDate1x, NoWD1x ), SetField( WorkDate1x, FormatDate( [Last Played,0] , MM//dd//yyyy ) ) ) #/
/# SetField( WorkString, Now: Load( GVNow) LP: Load( GVLastPlayed ) GVWD1: Load( GVWorkDate1x ) WD1: [WorkDate1x] GVWD2: Load( GVWorkDate2x ) WD2: [WorkDate2x] GVWL2: Load( GVWorkList2x ) WL2: [WorkList2x] GVWL1: Load( GVWorkList1x ) WL1: [WorkList1x] ) #/
/# If( Or( And( IsEmpty( [WorkDate1x] ), IsEmpty( [Last Played] ) ), IsEmpty( [WorkDate1x] ) ),
Save( , GVWorkDays1x ),
Save( FormatNumber( Extract(2, CompareDates( ConvertDate( [WorkDate1x] ), Now(), d ), days), 0 ), GVWorkDays1x ) ) #/
/# SetField( WorkString, Now: Load( GVNow) LP: Load( GVLastPlayed ) Days: Load( GVWorkDays ) GVWD1: Load( GVWorkDate1x ) WD1: [WorkDate1x] GVWD2: Load( GVWorkDate2x ) WD2: [WorkDate2x] GVWL2: Load( GVWorkList2x ) WL2: [WorkList2x] GVWL1: Load( GVWorkList1x ) WL1: [WorkList1x] ) #/
/# If( Or( And( IsEmpty( [WorkDate2x] ), IsEmpty( [WorkDate1x] )), IsEmpty( [WorkDate2x] ) ),
Save( ,GVWorkDays2x ),
Save( formatnumber(Extract(2, CompareDates( ConvertDate( [WorkDate2x] ), ConvertDate( [WorkDate1x] ), d), days ), 0 ), GVWorkDays2x ) ) #/
/# SetField( WorkString, Now: Load( GVNow) LP: Load( GVLastPlayed ) Day1: Load( GVWorkDays ) GVWD1: Load( GVWorkDate1x ) WD1: [WorkDate1x] Day2: Load( GVWorkDays2x ) GVWD2: Load( GVWorkDate2x ) WD2: [WorkDate2x] GVWL2: Load( GVWorkList2x ) WL2: [WorkList2x] GVWL1: Load( GVWorkList1x ) WL1: [WorkList1x] ) #/
/# SetField( WorkDays1x, Load( GVWorkDays1x ) ) #/
/# SetField( WorkDays2x, Load( GVWorkDays2x ) ) #/
/# SetField( WorkString, Now: Load( GVNow) LP: FormatDate( ConvertDate( Load( GVLastPlayed ) ) MM//dd//yyyy ) GDays1: Load( GVWorkDays ) GVWD1: FormatDate( ConvertDate( Load( GVWorkDate1x ) ) MM//dd//yyyy )  WD1: FormatDate( ConvertDate( [WorkDate1x] ) MM//dd//yyyy ) GDays2: Load( GVWorkDays2x ) GVWD2: FormatDate( ConvertDate( Load( GVWorkDate2x ) ) MM//dd//yyyy ) WD2: FormatDate( ConvertDate( [WorkDate2x] ) MM//dd//yyyy ) GVWL2: Load( GVWorkList2x ) WL2: [WorkList2x] GVWL1: Load( GVWorkList1x ) WL1: [WorkList1x] ) #/
,
If( Not(IsPlaying()),
FormatDate( Now(), hh:mm:ss )
SetField( WorkString, CTR: Load( GVWorkCounter ) )
Save( 0, GVWorkCounter ) 
SetField( WorkString, Ctr: [GVWorkCounter] )
If( IsEmpty( [SmartList] ), SetField( WorkList1x, NoWL1x ), SetField( WorkList1x, [SmartList] ) )
If( IsEmpty( [GVWorkList2x] ), SetField( WorkList2x, No ), SetField( WorkList2x, Load( GVWorkList2x ) ) ), )
)

Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2376

Yikes!

The AfterPlayback expression should be executing only once per started file. If you're testing the expression in Zelda or by adding it as an Expression Column, then yes, it will execute many times.

Note that /# ... #/  does NOT comment out a line, MC still executes it. MC has no code comments (Zelda adds '## comment' support, but that's only within Zelda).

Do you really need all those SetField() calls? You can likely use Global variables with Save() instead. What's the end result that you actually need?

One item that stands out to me is the [SmartList] field. Is that a calculated field? Depending on the expression there, it may be causing your slowdown.
Logged

rbmjr

  • World Citizen
  • ***
  • Posts: 107

Thanks for the reply, sorry for the delay in responding. I have worked with the After Playback, the problem at the moment is that I cannot fit everything in the After Playback dialog box. I believe that a regular expression dialog box will be included in the next release.

The SmartList field is filled upon music selection. It lets me know if the title came from one of several categories; Date Imported, Last Played, Never Played, Number Plays, and Random. As shown in the attached picture I enhance those categories by identifying the decade the music came from.

My music selection process seemed like it was reselecting the same tunes over and over again instead of choosing new music. Date Imported is the exception as I have not imported any new music since I've been working on this.

I am thinking as an interim solution to save all my global variable values into a single delimited string in the After Playback area then writing a separate smartlist script to parse and place the values into the appropriate fields. Any thoughts on if this would work?

Thanks for the heads up that /# and #/ are not appropriate for comments. I will update my code accordingly.
Logged
Pages: [1]   Go Up