Script Helper Methods
Moderators: Gurus, Addon Administrators
Script Helper Methods
Shared Helper Scripts (with subs, functions and constants):
These helper method utility files will be required in almost all of my future scripts.
They have the intention of sharing commonly used methods between scripts.
This "concept" is experimental! The utility files will get updated and can change. Please take this into account.
http://home.tiscali.be/ruben.castelein/ ... ntrols.vbs
http://home.tiscali.be/ruben.castelein/ ... eneral.vbs
http://home.tiscali.be/ruben.castelein/ ... ty_SQL.vbs
Utility Controls mirror
Utility General mirror
These files have to be put in MediaMonkey's Scripts folder.
If you have useful methods (subs and functions) for "General", "Controls", "SQL", ... please share them so I can add them. I'm still adding them myself.
The intention is to bundle nicely written pieces of code, with appropriate explanation, and "release dates" for these files, in the future.
They can be a great way of easily adding new functionality to MediaMonkey (e.g. writing/reading ID3 frames)
Cheers
Steegy
These helper method utility files will be required in almost all of my future scripts.
They have the intention of sharing commonly used methods between scripts.
This "concept" is experimental! The utility files will get updated and can change. Please take this into account.
http://home.tiscali.be/ruben.castelein/ ... ntrols.vbs
http://home.tiscali.be/ruben.castelein/ ... eneral.vbs
http://home.tiscali.be/ruben.castelein/ ... ty_SQL.vbs
Utility Controls mirror
Utility General mirror
These files have to be put in MediaMonkey's Scripts folder.
If you have useful methods (subs and functions) for "General", "Controls", "SQL", ... please share them so I can add them. I'm still adding them myself.
The intention is to bundle nicely written pieces of code, with appropriate explanation, and "release dates" for these files, in the future.
They can be a great way of easily adding new functionality to MediaMonkey (e.g. writing/reading ID3 frames)
Cheers
Steegy
Last edited by Steegy on Fri Feb 03, 2006 11:19 am, edited 1 time in total.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
This is a nice idea.
Can I suggest an improvment for your "GetINIPath" function though:
Can I suggest an improvment for your "GetINIPath" function though:
Code: Select all
Function getinipath()
Dim ini1,ini2,found,path1,path2
found = 0
getinipath = ""
path2 = SDB.MyMusicPath&"MediaMonkey\MediaMonkey.ini"
If fso.FileExists(path2) Then
found = 2
Set ini2 = fso.GetFile(path2)
End If
path1 = SDB.ApplicationPath&"MediaMonkey.ini"
If fso.FileExists(path1) Then
found = found + 1
Set ini1 = fso.GetFile(path1)
End If
Select Case found
case 1 'found only ini 1
getinipath = path1
case 2 'found only ini 2
getinipath = path2
case 3 'found both so use largest
If ini1.Size > ini2.Size Then
getinipath = path1
Else
getinipath = path2
End If
End Select
Set ini1 = Nothing
Set ini2 = Nothing
End Function
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.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Thank You.
But please, can you explain to me:
I thought MediaMonkey always uses the "MediaMonkey.ini" file in directory "My Documents\My Music\MediaMonkey\" (or similar) ?
If it doesn't exist, it is automaticly created.
Isn't the program folder ini just used for some winamp script compatibility?
I'm confused now...
Cheers
Steegy
But please, can you explain to me:
I thought MediaMonkey always uses the "MediaMonkey.ini" file in directory "My Documents\My Music\MediaMonkey\" (or similar) ?
If it doesn't exist, it is automaticly created.
Isn't the program folder ini just used for some winamp script compatibility?
I'm confused now...
Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
This answers your question...
http://www.mediamonkey.com/forum/viewtopic.php?t=7766
I have one though. How can i call those functions from another vbs file?
http://www.mediamonkey.com/forum/viewtopic.php?t=7766
I have one though. How can i call those functions from another vbs file?
The new release will include new function:
and so usage of these scripts will be easier. Note though, that doing so increases start-up time of your script slightly and so if you need only one function from another file, it might be better to copy that function to your script and save scripting engine parsing of whole included script file.
Jiri
Code: Select all
Script.Include "script name.vbs"
Jiri
Yes, I moved the .ini file from my music folder and added the DBName entry so that I could keep all my music (and the MM app) on my external harddrive, meaning I can use it at work without needing to copy any files onto my work machine.
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.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
@psyxonova
See a new script SwitchFields http://www.mediamonkey.com/forum/viewtopic.php?t=7920 where I use this. (see imports section + it uses one function written at the end of the file)
This is only a "preview" what means that I wanted to share the idea and invite all scripters to add (and improve) functionality of these helper scripts. I suppose we'd better wait with using this concept extensively, until these helper files are "approved" and contain more useful things.
I think it would be the best if we all use the same helper scripts (e.g. "Utility_General.vbs" and "Utility_SQL.vbs", ...) instead of all having us own (e.g. "HelperScript_Psyxonova.vbs", "TrixmotoHelpers.vbs", "SteegyUtility.vbs", ...) what would cause a lot of problems, instead of making things better, imho.
@jiri
I suppose this Script.Include method does the same thing of what I am doing in my SwitchFields script?
Actually, I had something in my mind so you could let MediaMonkey make references to helper methods.
E.g. if helper script "Utility_General.vbs" contains a function GetIniFile(), then you could use something like
Script.Use "Utility_General.vbs", "GetIniFile"
Then, everytime GetIniFile is used in the program, it would executed the referenced code in the "Utility_General.vbs" file. (instead of including the whole script file as it is now). That would work much faster.
It might even be better if we could use "Gen.GetIniFile" (where "Gen" indicated a class) so there would be less problems with
naming collisions and methods would be easier to recognise. (e.g. SQL.OpenDatabaseConnection("MyDB.mdb") )
Any way, with referenced scripts, it should also be possible for one referenced method to use another (not referenced) method in the same helper file.
This is probably much too difficult to create, but it would be very cool and would make helper scripts useful without extra overhead.
Anyway, thank you very much for responding so fast and to implement this first method! You really are helping scripting for MM a lot (with this, with added menu references, new events, ...)
Cheers
Steegy
See a new script SwitchFields http://www.mediamonkey.com/forum/viewtopic.php?t=7920 where I use this. (see imports section + it uses one function written at the end of the file)
This is only a "preview" what means that I wanted to share the idea and invite all scripters to add (and improve) functionality of these helper scripts. I suppose we'd better wait with using this concept extensively, until these helper files are "approved" and contain more useful things.
I think it would be the best if we all use the same helper scripts (e.g. "Utility_General.vbs" and "Utility_SQL.vbs", ...) instead of all having us own (e.g. "HelperScript_Psyxonova.vbs", "TrixmotoHelpers.vbs", "SteegyUtility.vbs", ...) what would cause a lot of problems, instead of making things better, imho.
@jiri
I suppose this Script.Include method does the same thing of what I am doing in my SwitchFields script?
Actually, I had something in my mind so you could let MediaMonkey make references to helper methods.
E.g. if helper script "Utility_General.vbs" contains a function GetIniFile(), then you could use something like
Script.Use "Utility_General.vbs", "GetIniFile"
Then, everytime GetIniFile is used in the program, it would executed the referenced code in the "Utility_General.vbs" file. (instead of including the whole script file as it is now). That would work much faster.
It might even be better if we could use "Gen.GetIniFile" (where "Gen" indicated a class) so there would be less problems with
naming collisions and methods would be easier to recognise. (e.g. SQL.OpenDatabaseConnection("MyDB.mdb") )
Any way, with referenced scripts, it should also be possible for one referenced method to use another (not referenced) method in the same helper file.
This is probably much too difficult to create, but it would be very cool and would make helper scripts useful without extra overhead.
Anyway, thank you very much for responding so fast and to implement this first method! You really are helping scripting for MM a lot (with this, with added menu references, new events, ...)
Cheers
Steegy
Last edited by Steegy on Tue Jan 31, 2006 9:51 am, edited 1 time in total.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
@Trixmoto and other scripters
Is this better?
To the dev's:
Why does MediaMonkey use a different program folder INI configuration file for the skinned and the non-skinned version? Do we need to use both (e.g. in the above function)? The INI filenames are made out of the filename of the MediaMonkey executable. Is there an easy way to get this executable filename (or don't we have to bother and always use "MediaMonkey.ini")?
Cheers
Steegy
Is this better?
Code: Select all
' Returns the path to MediaMonkey's configuration (ini) file or "" if it doesn't exist
Function GetINIPath()
GetINIPath = ""
Dim FoundININumber, INIPath_MyMusic, INIPath_Program, FSO
FoundININumber = 0
INIPath_MyMusic = SDB.MyMusicPath & "MediaMonkey\MediaMonkey.ini"
INIPath_Program = SDB.ApplicationPath & "MediaMonkey.ini"
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(INIPath_MyMusic) Then FoundININumber = FoundININumber + 1
If FSO.FileExists(INIPath_Program) Then FoundININumber = FoundININumber + 2
Select Case FoundININumber
Case 1:
GetINIPath = INIPath_MyMusic
Case 2:
GetINIPath = INIPath_Program
Case 3:
If FSO.GetFile(INIPath_MyMusic).Size > FSO.GetFile(INIPath_Program).Size Then
GetINIPath = INIPath_MyMusic
Else
GetINIPath = INIPath_Program
End If
End Select
End Function
To the dev's:
Why does MediaMonkey use a different program folder INI configuration file for the skinned and the non-skinned version? Do we need to use both (e.g. in the above function)? The INI filenames are made out of the filename of the MediaMonkey executable. Is there an easy way to get this executable filename (or don't we have to bother and always use "MediaMonkey.ini")?
Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Re. Ini file - the real ini file is stored in My Music\MediaMonkey folder, those created in MM folder are created by WinAmp compatible plug-ins (they use MM executable name as the base name for their .ini file and thus there are separate versions for skinned and non-skinned MM).
Re. Script.Include - it wouldn't help much to load only one method from a file, the main tasks (read content of the file and parse the file in order to find the function) would have to be done anyway. The delay won't be terrible, I just wanted to warn scripters to not include several thousands lines of scripts in each script they write.
Jiri
Re. Script.Include - it wouldn't help much to load only one method from a file, the main tasks (read content of the file and parse the file in order to find the function) would have to be done anyway. The delay won't be terrible, I just wanted to warn scripters to not include several thousands lines of scripts in each script they write.
Jiri
Personally I have a long text file with useful methods which I use, but I always copy and paste them into a script if I need them. I thinik most script users (who are not script writers) prefer to have a single script file as it is easier for them to install.
The ini path function is definitely better now as it should always find the main ini file.
The ini path function is definitely better now as it should always find the main ini file.
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.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
I wish MM would store all configuration data within its program directory instead of using the windows method of storing them in the user profiles.
Ideally, you could still keep separate user ini files, under a mediamonkey\user folder if so desired.
this would help imensely those who run MM from a shared location, like a network drive or an external drive/mp3 player.
Ideally, you could still keep separate user ini files, under a mediamonkey\user folder if so desired.
this would help imensely those who run MM from a shared location, like a network drive or an external drive/mp3 player.
New script: Last.FM Node Now with DJ Mode!
Last.fm + MediaMonkey = Scrobbler DJ!
Tag with MusicBrainz ~ Get Album Art!
Tweak the Monkey! ~ My Scripts Page
Last.fm + MediaMonkey = Scrobbler DJ!
Tag with MusicBrainz ~ Get Album Art!
Tweak the Monkey! ~ My Scripts Page
So what I'm been told about "use the one with the biggest size" and the "shared environment" stuff isn't true? We should only use the SDB.MyMusicPath & "MediaMonkey\MediaMonkey.ini" one then?Re. Ini file - the real ini file is stored in My Music\MediaMonkey folder, those created in MM folder are created by WinAmp compatible plug-ins (they use MM executable name as the base name for their .ini file and thus there are separate versions for skinned and non-skinned MM).
Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
I don't have a My Music folder, so this wouldn't work for me. I don't even have a MediaMonkey.ini file on my computer. Mine is stored here: "F:\Applications\MediaMonkey\MediaMonkey.ini"
If you create MediaMonkey.ini in the same folder as your MediaMonkey.exe then this one will override the one in your my music folder. Presumably on a key-by-key basis. But I just moved the .ini file and a new one was never created in my music, but the one in the program folder is always updating.
If you create MediaMonkey.ini in the same folder as your MediaMonkey.exe then this one will override the one in your my music folder. Presumably on a key-by-key basis. But I just moved the .ini file and a new one was never created in my music, but the one in the program folder is always updating.
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.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
OK, I just refreshed my Readme-knowledge:
How does MediaMonkey decide which INI to use? Does it first check the INI in the program folder for the [system] section? And if it doesn't find the [system] section, it uses the one in MyMusic subfolder?
Cheers
Steegy
The comparation of file sizes between different ini files can't be the right way. If you copy MyMusicINI to ProgramINI and then delete your 100 magic nodes, the ProgramINI files would be smaller than the other one. Therefor, the script would "detect" MyMusicINI as larger and would use that one. But that is wrong because MediaMonkey would be using the ProgramINI one.If you wish to share MediaMonkey's configuration file and or database among multiple users:
i) Move the MediaMonkey.ini file to the \Program Files\MediaMonkey directory.
How does MediaMonkey decide which INI to use? Does it first check the INI in the program folder for the [system] section? And if it doesn't find the [system] section, it uses the one in MyMusic subfolder?
Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).