Another script feature desired:

Post a reply

Visual Confirmation

To prevent automated access and spam, you are required to confirm that you are human. Please place a check mark next to all images of monkeys or apes. If you cannot see any images, please contact the Board Administrator.

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review
   

Expand view Topic review: Another script feature desired:

Re: Another script feature desired:

Post by trixmoto » Tue Jul 26, 2011 3:00 am

I often use the SDB.Objects method to hold a Dictionary object of string/numeric/boolean values, it would be handy if there was an SDB.Data method that allowed you to hold these directly, I agree.

Re: Another script feature desired:

Post by mcow » Mon Jul 25, 2011 2:16 pm

mcow wrote:I could do something hacky like create a temp file or set a registry key from the script, which I would then monitor from within my program, but that's really not very elegant.


The point is, it would be better to have a single interface to deal with. There are several ways to implement this now, but they're all secondary.

Re: Another script feature desired:

Post by trixmoto » Mon Jul 25, 2011 3:23 am

How about using the registry to hold the flag?

Another script feature desired:

Post by mcow » Sun Jul 24, 2011 5:33 pm

I'm working on a program that will run as a separate process but will interact with MediaMonkey. The intent is for the script to have no UI of its own. I would like to allow the user to stop my program on demand by putting a Terminate script in the Tools|Scripts menu.

The problem is, there is no good API for signaling my program. I'm really only looking for a boolean flag that I can set within the MM script, and read, then reset, from within my program; or else a message that I could somehow send. But there is no general-purpose inter-script communication. I have tried setting a value in SDB.Objects(), which works to signal my program but my program can't reset the value of what gets returned -- because the COM model exposes SDB.Objects() as a method rather than as an object reference.
Something like Script.Terminate would seem to be ideal, but that's really designed to end scripts running with MM, and anyway I don't see how to set it from a script.
I could do something hacky like create a temp file or set a registry key from the script, which I would then monitor from within my program, but that's really not very elegant. I could create a channel, such as a named-pipe, to allow me to send the message, but that's a lot of work for a simple one-off communication. I could also simply tell the user to kill the process, which is not dangerous in my case but doesn't allow a clean shutdown.

My current workaround, which is a total hack but simple, is to have the Terminate script set the ComServerUIActive flag to True, then monitor that with my program; when it goes True, the program resets it to False and terminates. But that's not what that flag is used for; I can only get away with it because it's such an obscure value that neither MM or any other add-on is likely to be making use of it. (I don't need to use it as it's intended because I monitor the Shutdown message in my program.)

What I would like is a general-purpose Script.Data() technique where any script could set data with a particular key. For my purpose, simple boolean data would be sufficient (i.e., Script.GetFlag(name) and Script.SetFlag(name, value)), or even a generic event (i.e., SDB.Broadcast(message) which would trigger an "OnBroadcast" COM event).

Top