Questions from scripting beginners

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

Moderator: Gurus

holterpolter
Posts: 292
Joined: Wed Feb 01, 2006 7:29 am
Location: Germany

Questions from scripting beginners

Post by holterpolter » Fri Dec 19, 2008 9:57 am

The purpose of this thread is to create a place where beginners in scripting can easily pose question and hopefully get quick answers. Questions like how do i realize this and that problem. And than exchange their progress in scripting skills.
So my question is
How do i set up my development environment right? I try to develop an AutoScript for MM and i use PSPad as an editor. Every time i change something in the script i have to restart MM. Isn´t there an easier solution to force MM to reload the autoscripts?

Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Re: Questions from scripting beginners

Post by Bex » Fri Dec 19, 2008 1:23 pm

The only other way is to create an installer of the script which you then use to install the update.
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts

Teknojnky
Posts: 5533
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Re: Questions from scripting beginners

Post by Teknojnky » Fri Dec 19, 2008 2:11 pm

you can create a script.ini entry to manually trigger the onstartup sub, that should work but you may need to perform checks within the script to make sure your not running multiple instances of the script.

holterpolter
Posts: 292
Joined: Wed Feb 01, 2006 7:29 am
Location: Germany

Re: Questions from scripting beginners

Post by holterpolter » Thu Mar 12, 2009 12:58 pm

How does this work with OpenSQL

Code: Select all

Dim listToAdd
Dim iter : Set Iter = SDB.Database.QuerySongs(strWhere)          
Do Until Iter.EOF
   listToAdd.Add(iter.item)
   Iter.next
Loop
I tried quite the same with a more complex SQL Querry in the new 3.1 beta

Code: Select all

strSQL = "SELECT * FROM Songs WHERE (SOUNDEX(Artist) = SOUNDEX('REM')) AND (SOUNDEX(SongTitle) = SOUNDEX('so central rain'))"         
Dim iter: Set Iter = SDB.Database.OpenSQL(strsql)
Do Until Iter.EOF  
    listToAdd.Add(iter)
    Iter.next
Loop
But it produces an error. Can somebody help me to find the mistake?

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Questions from scripting beginners

Post by trixmoto » Fri Mar 13, 2009 6:06 am

"OpenSQL" returns a "SDBDBIterator" object not a "SDBSongIterator" object like "QuerySongs" does. This means that it returns string and numeric values, not the song object itself.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.

holterpolter
Posts: 292
Joined: Wed Feb 01, 2006 7:29 am
Location: Germany

Re: Questions from scripting beginners

Post by holterpolter » Fri Mar 13, 2009 12:01 pm

This is the point. Isn´t it possible to get the song object via OpenSQL?
I used "QuerySongs" in my first tests and everything worked fine with the song objects.
Later i wanted to create more complex SQL Queries and thought all i have to do is to exchange the "QuerySongs" method with "OpenSQL" Method. But this leads to a more complicated situation, because i can´t get the song Object.
Never the less, after trying for a few days i realized that i don´t need to use OpenSQL and i can work with QuerySongs.
:P

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Questions from scripting beginners

Post by trixmoto » Sat Mar 14, 2009 9:20 am

There is no way to directly get the song object from OpenSQL. It is however possible to use OpenSQL to return a list of song IDs and then use QuerySongs to return the song objects for this list of IDs.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.

Post Reply