Best Practices for Script Writing

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

sterlingm
Posts: 27
Joined: Wed Feb 19, 2020 4:54 pm

Best Practices for Script Writing

Post by sterlingm »

What are the best practices you'd recommend for writing scripts (currently using VBS) inside MediaMonkey?

I ask because the current process I'm using is:

1 - Write some code. Usually a single function/sub.
2 - Add to mmip file.
3 - Uninstall current add-on.
4 - Install new add-on (hopefully without error)
5 - Test newly written code to make sure it does what I was expecting. If not start again at step 1.

This means I'm stuck writing tiny junks of code and testing/validating every function/sub written every time it is written to ensure it isn't the one breaking the code. This gets very annoying when a function relies on another function and multiple functions/sub need to be written at once. I'm still new to vbs so tracking down the exact cause of an unknown error can be time consuming.

Is there a better way to do this?

Understand MediaMonkey is needed because many of the vbs language utilizes MM specific functions which are not available if I were to write it and test outside of MM.

Just wondering.
Thanks.
-Sterling
Peke
Posts: 17861
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: Best Practices for Script Writing

Post by Peke »

Hi,
There is no need for new MMIP and all other steps.

See https://www.mediamonkey.com/wiki/index. ... ol::Reload where you can put it as first line (Or at functions that you currently work on) and MM Will Always use latest VBS Version :)

eg.

Code: Select all

Script.Reload(Script.ScriptPath)
You can see Last.Fm plugin.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
sterlingm
Posts: 27
Joined: Wed Feb 19, 2020 4:54 pm

Re: Best Practices for Script Writing

Post by sterlingm »

Thank you for the reply.

I've read that page. I'm assuming you have to put this inside your vbs script. Yes?

As per your reply, I've tried it. At the start of my script.

'''''''''''''''''''''''''' DEBUG '''''''''''''''''''''''''''''''''''''''
Script.Reload(Script.ScriptPath)
'''''''''''''''''''''''''' DEBUG '''''''''''''''''''''''''''''''''''''''

It is not inside a sub or function. Does it need to be in a sub? Which sub?

For those who don't read (understand) script documentation terminology/syntax is there an example to follow?

I really do appreciate the reply and I'm glad to hear there is a method to avoid all those steps. I just wish the documentation had more robust (or any) examples.

Thank you,
-Sterling

PS(To be clear this is not reloading the script.)
Peke
Posts: 17861
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: Best Practices for Script Writing

Post by Peke »

Hi,
Yes Last.FM plugin uses it and from "!LastFM.Options.vbs" you can see why an dwhen is used:

Code: Select all

Sub InitSheet( Sheet)
  Script.Reload(Script.ScriptPath) 'Script Reload on INIT Sheet so that updates can be checked
Sent you PM to speed this up and we can post results here for future Scripters.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
sterlingm
Posts: 27
Joined: Wed Feb 19, 2020 4:54 pm

Re: Best Practices for Script Writing

Post by sterlingm »

Thanks for the links on skype.
You mentioned the errors are occurring because objects aren't being used in the variables and so they are being wiped when the script is reloaded.

Since this looks like a complete rewrite of the base code is required, I'd rather not spend time using vbs for this since it wouldn't be usable for MM5.

I'd like to rewrite this in javascript. I just posted to the developer forum but will ask here as well.

Is there a sample javascript example showing how to get started? A "hello world" for javascript in MM?
The examples I'm using aasearch and lyricsearch are not very clear.

Thanks.
-Sterling
Peke
Posts: 17861
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: Best Practices for Script Writing

Post by Peke »

Hi,
The best start would be to Extract MMIP plugins (RAR/7Zip) from MM5\SampleScripts folder and involved in MM5 Forum Part.

The best thing is that as MM5 is more actively developed you can influence what is added and needed.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
sterlingm
Posts: 27
Joined: Wed Feb 19, 2020 4:54 pm

Re: Best Practices for Script Writing

Post by sterlingm »

Thank you. I didn't know that was there. I'll download MM5 and take a look.
It still would be nice to have these online as part of the documentation though.

Just a thought.
Thanks.
-Sterling
Peke
Posts: 17861
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: Best Practices for Script Writing

Post by Peke »

Hi,
There is see https://www.mediamonkey.com/forum/viewt ... 27&t=81285 you can also browse thru Dev forum.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
sterlingm
Posts: 27
Joined: Wed Feb 19, 2020 4:54 pm

Re: Best Practices for Script Writing

Post by sterlingm »

I stand corrected. Thanks. I guess I wasn't reading as clearly as I thought. I'll give it a shot now that I have examples and such to examine.

Appreciate the patience and replies.

-Sterling
Peke
Posts: 17861
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: Best Practices for Script Writing

Post by Peke »

Hi,
Sure, my pleasure. Please be patient with us as MM5 API is still in its infant staged where MMW API was expanded over 15 Years ;)

Feel free to throw at us anything you miss or do not understand in MM5 Forums.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
Post Reply