Sample Read and Write Method(s): Difference between revisions

From MediaMonkey Wiki
Jump to navigation Jump to search
No edit summary
 
(11 intermediate revisions by one other user not shown)
Line 1: Line 1:
  '
{| align="right"
  ' MediaMonkey Script
| __TOC__
  '
|}
  ' NAME: WikiSample.vbs
==Instructions==
  '
# Copy the sample code into a text editor
  ' Template Author: MoDementia
# Replace highlighted terms with information from the items page in the Property Summary Table [[ISDBSongData::Title|Title]] e.g.
  ' Generated by MMWiki page {{PAGENAME}}
## Value Name = Title
' Time, DATE :  {{CURRENTTIME}}, {{CURRENTDAY2}} {{CURRENTMONTHNAME}} {{CURRENTYEAR}}
## Value Type = String
  '
## Field Name = SongTitle
  'Sample of Scripting Code for inclusion into MMWiki pages
## Database Table = Songs
  'A working script to show database results using various selection methods
# Change the SelectMethod = 1 to a number corresponding to the select method required e.g.
  '
## SelectMethod = 2 would use SQLQuery Method
  'MediaMonkey\Scripts\Scripts.in entry
# Comment all lines that DO NOT match the SelectMethod chosen by adding a single quote to the front of the line e.g. If SelectMethod was set as 3 all lines with 'SelectMethod not containing 2 would need to be commented out (or removed)
  '
## ' For iCounter = 0 to objSongList.count - 1                                        'SelectMethod '''4''' SongLists
  '[WikiSample]                                                             '[[Introduction_to_scripting#Format_of_the_Scripts.ini_file|Format of the Scripts.ini file]]
# Save the file as WikiSample.vbs in ...MediaMonkey\Scripts folder
  'Filename=WikiSample.vbs
# Edit the ...MediaMonkey\Scripts\Scripts.ini and add (copy/paste the section between '<-- Start ini code and '<--- End ini code) and save
  'Procname=WikiSample
# Start MM and select menu Tools --> Scripts --> WikiSample
  'Order=99
'''Note:''' If Value Type = Object you will need to add the Member Name to the code e.g. ObjectAlbum = objSongData.Album.Member<br>
  'DisplayName=WikiSample
 
  'Description=Displays the raw database value of the MMWikipage item
==Sample Code==
  'Language=VBScript
  <span style="color: #808080;">'</span>
  'ScriptType=0
  <span style="color: #808080;">' MediaMonkey Script</span>
  <span style="color: #808080;">'</span>
  <span style="color: #808080;">' NAME: WikiSample.vbs</span>
  <span style="color: #808080;">'</span>
  <span style="color: #808080;">' Template Author: MoDementia</span>
  <span style="color: #808080;">' Time, DATE :  22:31, 09 April 2008</span>
  <span style="color: #808080;">'</span>
  <span style="color: #808080;">'Sample of Scripting Code Read and Write Method(s)</span>
  <span style="color: #808080;">'A working script to show database results using various selection methods</span>
  <span style="color: #808080;">'</span>
  <span style="color: #808080;">'MediaMonkey\Scripts\Scripts.ini entry</span>
<span style="color: #808080;">'</span>
  <span style="color: #808080;">'<-- Start ini code</span>
  <span style="color: #808080;">'[WikiSample]</span>                                                                      '[[Introduction_to_scripting#Format_of_the_Scripts.ini_file|Format of the Scripts.ini file]]
  <span style="color: #808080;">'Filename=WikiSample.vbs</span>
  <span style="color: #808080;">'Procname=WikiSample</span>
  <span style="color: #808080;">'Order=99</span>
  <span style="color: #808080;">'DisplayName=WikiSample</span>
  <span style="color: #808080;">'Description=Displays the raw database value of the MMWikipage item</span>
  <span style="color: #808080;">'Language=VBScript</span>
  <span style="color: #808080;">'ScriptType=0</span>
<span style="color: #808080;">'<-- End ini code</span>
   
   
  <span style="color: #b1b100;">Sub</span> WikiSample
  <span style="color: #b1b100;">Dim</span> SelectMethod, SampleID, <span style="background:#CCFFCC;">Value Type</span>New<span style="background:#FFCC99;">Value Name</span>
{{#ifeq:{{{3|-}}}|Object| |  <span style="color: #b1b100;">Dim</span> SQLString                                                                    'SelectMethod 3}}
  <span style="color: #b1b100;">Dim</span> objSongList                                                                  'SelectMethod 2
   
   
Sub WikiSample
  SelectMethod = <span style="color: #cc66cc;">1</span>
<span style="color: #b1b100;">Sub</span>
  <span style="color: #808080;">' SelectMethod NowPlaying = 1</span>
   Dim SelectMethod, SampleID, {{{3|-}}}New{{{2|-}}}
   <span style="color: #808080;">' SelectMethod UseSQLQuery = 2</span>
{{#ifeq:{{{3|-}}}|Object| |  Dim SQLString                                                            'SelectMethod 3}}
{{#ifeq:{{{3|-}}}|Object| |  <span style="color: #808080;">' SelectMethod UseSQL = 3</span>}}
   Dim objSongList                                                          'SelectMethod 2
   <span style="color: #808080;">' SelectMethod SelectedSongs = 4</span>
   
   
  SelectMethod = 1
<span style="color: #808080;">'  SampleID = 13123                                                                  'Usualy Set in another part of the script</span>
   ' SelectMethod NowPlaying = 1
<span style="color: #808080;">'Random SampleID Code (Remove if SampleID known)</span>
   ' SelectMethod UseSQLQuery = 2
  <span style="color: #aaaaaa;"> Set iter = SDB.Database.OpenSQL("SELECT DISTINCT Songs.ID FROM Songs ORDER BY RANDOM() Limit 1")
{{#ifeq:{{{3|-}}}|Object| |  ' SelectMethod UseSQL = 3}}
   While Not iter.EOF
   ' SelectMethod SelectedSongs = 4
    SampleID = iter.StringByIndex(0)
  iter.Next
   Wend</span>
<span style="color: #808080;">'End of random SampleID code</span>
  <span style="background:#CCFFCC;">Value Type</span>New<span style="background:#FFCC99;">Value Name</span> = <span style="color: #ff0000;">"Mamma Mia"</span>
   <span style="color: #b1b100;">Set</span> objSongList = SDB.<span style="color: #66cc66;">NewSongList</span>                                                'SelectMethod 2 and 3 [[ISDBApplication::NewSongList|SDB.NewSongList]]
    
    
   SampleID = 13123
   Select <span style="color: #b1b100;">Case</span> SelectMethod
  {{{3|-}}}New{{{2|-}}} = "Mamma Mia"
    <span style="color: #b1b100;">Case</span> <span style="color: #cc66cc;">1</span>
  Set objSongList = SDB.NewSongList                                       'SelectMethod 2 and 3 [[ISDBApplication::NewSongList|SDB.NewSongList]]
      <span style="color: #b1b100;">Set</span> objSongData = SDB.<span style="color: #66cc66;">Player.CurrentSong</span>                                      '[[ISDBPlayer::CurrentSong|SDB.Player.CurrentSong]]
    <span style="color: #b1b100;">Case</span> <span style="color: #cc66cc;">2</span>
      <span style="color: #b1b100;">Set</span> objSongListiterator = SDB.Database.<span style="color: #66cc66;">QuerySongs(</span><span style="color: #ff0000;">"AND Songs.ID="</span> & SampleID<span style="color: #66cc66;">)</span> '[[ISDBDatabase::QuerySongs|SDB.Database.QuerySongs]]
{{#ifeq:{{{3|-}}}|Object| |    <span style="color: #b1b100;">Case</span> <span style="color: #cc66cc;">3</span>}}
{{#ifeq:{{{3|-}}}|Object| |      SQLString = <span style="color: #ff0000;">"SELECT</span> <span style="background:#CC99FF;">Field Name</span> <span style="color: #ff0000;">FROM</span> <span style="background:#CC99FF;">Database Table</span> <span style="color: #ff0000;">WHERE</span> <span style="background:#CC99FF;">Database Table</span><span style="color: #ff0000;">.ID = "</span> & SampleID}}
{{#ifeq:{{{3|-}}}|Object| |      <span style="color: #b1b100;">Set</span> objSongStringiterator = SDB.Database.<span style="color: #66cc66;">OpenSQL(</span>SQLString<span style="color: #66cc66;">)</span>                    '[[ISDBDatabase::OpenSQL|SDB.Database.OpenSQL]]}}
    <span style="color: #b1b100;">Case</span> <span style="color: #cc66cc;">4</span>
      <span style="color: #b1b100;">Set</span> objSongList = SDB.<span style="color: #66cc66;">SelectedSongList</span>                                       '[[ISDBApplication::SelectedSongList|SDB.SelectedSongList]]
<span style="color: #808080;">'      Set objSongList = SDB.CurrentSongList</span>                                      '[[ISDBApplication::CurrentSongList|SDB.CurrentSongList]]
<span style="color: #808080;">'      Set objSongList = SDB.AllVisibleSongList</span>                                    '[[ISDBApplication::AllVisibleSongList|SDB.AllVisibleSongList]]
    <span style="color: #b1b100;">Case Else</span>
      SDB.<span style="color: #66cc66;">MessageBox</span> <span style="color: #ff0000;">"Incorrect Select Method "</span>, mtError, Array<span style="color: #66cc66;">(</span>mbOK<span style="color: #66cc66;">)</span>              '[[ISDBApplication::MessageBox|SDB.MessageBox]]
      <span style="color: #b1b100;">Exit Sub</span>
  <span style="color: #b1b100;">End</span> Select
    
    
   Select Case SelectMethod
   For <span style="color: #b1b100;">iCounter</span> = <span style="color: #cc66cc;">0</span> <span style="color: #b1b100;">to</span> objSongList.<span style="color: #b1b100;">count</span> - <span style="color: #cc66cc;">1</span>                                        'SelectMethod 4 [[SDBSongList|SongLists]]
    Case 1
     <span style="color: #b1b100;">While Not</span> objSongListiterator.<span style="color: #b1b100;">EOF</span>                                              'SelectMethod 2 [[SDBDBIterator|Iterator]]
      Set objSongData = SDB.Player.CurrentSong                            '[[ISDBPlayer::CurrentSong|SDB.Player.CurrentSong]]
     <span style="color: #b1b100;">While Not</span> objSongStringiterator.<span style="color: #b1b100;">EOF</span>                                              'SelectMethod 3
    Case 2
       <span style="color: #b1b100;">Set</span> objSongData = objSongListiterator.<span style="color: #66cc66;">Item</span>                                    'SelectMethod 2
      Set objSongListiterator = SDB.Database.QuerySongs("AND Songs.ID=" & SampleID) '[[ISDBDatabase::QuerySongs|SDB.Database.QuerySongs]]
       objSongList.<span style="color: #66cc66;">Add(</span>objSongData<span style="color: #66cc66;">)</span>                                                  'SelectMethod 2
{{#ifeq:{{{3|-}}}|Object| |    Case 3}}
       <span style="color: #b1b100;">Set</span> objSongData = objSongList.<span style="color: #66cc66;">Item</span><span style="color: #66cc66;">(</span>iCounter<span style="color: #66cc66;">)</span>                                  'SelectMethod 4
{{#ifeq:{{{3|-}}}|Object| |      SQLString = "SELECT {{{5|-}}} FROM {{{4|-}}} WHERE {{{4|-}}}.ID = " & SampleID}}
       <span style="background:#CCFFCC;">Value Type</span><span style="background:#FFCC99;">Value Name</span> = objSongData.<span style="background:#FFCC99;">Value Name</span>{{#ifeq:{{{3|-}}}|Object|.Member}}                                 'SelectMethod 1, 2 and 4
{{#ifeq:{{{3|-}}}|Object| |      Set objSongListiterator = SDB.Database.OpenSQL(SQLString)            '[[ISDBDatabase::OpenSQL|SDB.Database.OpenSQL]]}}
       SDB.<span style="color: #66cc66;">MessageBox</span> <span style="color: #ff0000;">"Value = '"</span> & <span style="background:#CCFFCC;">Value Type</span><span style="background:#FFCC99;">Value Name</span> & <span style="color: #ff0000;">"'"</span>, mtError, <span style="color: #b1b100;">Array</span><span style="color: #66cc66;">(</span>mbOK<span style="color: #66cc66;">)</span> 'SelectMethod 4 (2 and 3)
     Case 4
{{#ifeq:{{{3|-}}}|Object| |      <span style="background:#CCFFCC;">Value Type</span><span style="background:#FFCC99;">Value Name</span> = objSongStringiterator.<span style="color: #66cc66;">StringByIndex(</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">)</span>                   'SelectMethod 3}}
      Set objSongList = SDB.SelectedSongList                              '[[ISDBApplication::SelectedSongList|SDB.SelectedSongList]]
     objSongListiterator.<span style="color: #b1b100;">Next</span>                                                        'SelectMethod 2
'      Set objSongList = SDB.CurrentSongList                              '[[ISDBApplication::CurrentSongList|SDB.CurrentSongList]]
    objSongStringiterator.<span style="color: #b1b100;">Next</span>                                                        'SelectMethod 3
'      Set objSongList = SDB.AllVisibleSongList                          '[[ISDBApplication::AllVisibleSongList|SDB.AllVisibleSongList]]
     <span style="color: #b1b100;">Wend</span>                                                                            'SelectMethod 2 and 3
     Case Else
   <span style="color: #b1b100;">Next</span>                                                                              'SelectMethod 4
      SDB.MessageBox "Incorrect Select Method ", mtError, Array(mbOK)      '[[ISDBApplication::MessageBox|SDB.MessageBox]]
   <span style="color: #b1b100;">Set</span> objSongListiterator=<span style="color: #b1b100;">Nothing</span>                                                  'SelectMethod 2
      Exit Sub
  <span style="color: #b1b100;">Set</span> objSongStringiterator=<span style="color: #b1b100;">Nothing</span>                                                  'SelectMethod 3
  End Select
 
  For iCounter = 0 to objSongList.count - 1                                'SelectMethod 4 [[SDBSongList|SongLists]]
    While Not objSongListiterator.EOF                                     'SelectMethod 2 and 3 [[SDBDBIterator|Iterator]]
       Set objSongData = objSongListiterator.Item                           'SelectMethod 2
       objSongList.Add(objSongData)                                         'SelectMethod 2
       Set objSongData = objSongList.Item(iCounter)                         'SelectMethod 4
       {{{3|-}}}{{{2|-}}} = objSongData.{{{2|-}}}{{#ifeq:{{{3|-}}}|Object|.Member}}                                     'SelectMethod 1, 2 and 4
       SDB.MessageBox "Value = '" & {{{3|-}}}{{{2|-}}} & "'", mtError, Array(mbOK) 'SelectMethod 4 (2 and 3)
{{#ifeq:{{{3|-}}}|Object| |      {{{3|-}}}{{{2|-}}} = objSongListiterator.StringByIndex(0)                  'SelectMethod 3}}
     objSongListiterator.Next                                               'SelectMethod 2 and 3
     Wend                                                                   'SelectMethod 2 and 3
   Next                                                                     'SelectMethod 4
   Set objSongListiterator=Nothing                                         'SelectMethod 2 and 3
   
   
   SDB.MessageBox "Value = '" & {{{3|-}}}{{{2|-}}} & "'", mtError, Array(mbOK)
   SDB.<span style="color: #66cc66;">MessageBox</span> <span style="color: #ff0000;">"Value = '"</span> & <span style="background:#CCFFCC;">Value Type</span><span style="background:#FFCC99;">Value Name</span> & <span style="color: #ff0000;">"'"</span>, mtError, <span style="color: #b1b100;">Array</span><span style="color: #66cc66;">(</span>mbOK<span style="color: #66cc66;">)</span>
   
   
  '  objSongData.{{{2|-}}}{{#ifeq:{{{3|-}}}|Object|.Member}} = {{{3|-}}}New{{{2|-}}} 'Commented Out For Safety 'SelectMethod 1, 2 and 4
  <span style="color: #808080;">'  objSongData.</span><span style="background:#FFCC99;">Value Name</span>{{#ifeq:{{{3|-}}}|Object|.Member}} = <span style="background:#CCFFCC;">Value Type</span>New<span style="background:#FFCC99;">Value Name</span> 'Commented Out For Safety       'SelectMethod 1, 2 and 4
  '  objSonglist.UpdateAll             'Commented Out For Safety           '[[SDBSongData|UpdateAll]]
  <span style="color: #808080;">'  objSonglist.UpdateAll</span>                            'Commented Out For Safety       '[[SDBSongData|UpdateAll]]
                           'SelectMethod 1, 2 and 4 Updates db and writes tags (if checked in options)
                           'SelectMethod 1, 2 and 4 Updates db and writes tags (if checked in options)
  End Sub
  <span style="color: #b1b100;">End Sub</span>
 
==Converted Sample Method 2==
<source lang="vb">
'
' MediaMonkey Script
'
' NAME: WikiSample.vbs
'
' Template Author: MoDementia
' Time, DATE :  22:31, 09 April 2008
'
'Sample of Scripting Code Read and Write Method(s)
'A working script to show database results using various selection methods
'
'MediaMonkey\Scripts\Scripts.ini entry
'
'<-- Start ini code
'[WikiSample]                                                                      'Format of the Scripts.ini file
'Filename=WikiSample.vbs
'Procname=WikiSample
'Order=99
'DisplayName=WikiSample
'Description=Displays the raw database value of the MMWikipage item
'Language=VBScript
'ScriptType=0
'<-- End ini code
 
Sub WikiSample
  Dim SelectMethod, SampleID, StringNewTitle
'  Dim SQLString                                                                    'SelectMethod 3
  Dim objSongList                                                                  'SelectMethod 2
 
  SelectMethod = 2
  ' SelectMethod NowPlaying = 1
  ' SelectMethod UseSQLQuery = 2
  ' SelectMethod UseSQL = 3
  ' SelectMethod SelectedSongs = 4
'  SampleID = 13123                                                                  'Usualy Set in another part of the script
'Random SampleID Code (Remove if SampleID known)
  Set iter = SDB.Database.OpenSQL("SELECT DISTINCT Songs.ID FROM Songs ORDER BY RANDOM() Limit 1")
  While Not iter.EOF
    SampleID = iter.StringByIndex(0)
  iter.Next
  Wend
  Set iter=Nothing
'End of random SampleID code
  StringNewTitle = "Mamma Mia"
  Set objSongList = SDB.NewSongList                                                'SelectMethod 2 and 3 SDB.NewSongList
  Select Case SelectMethod
    Case 1
      Set objSongData = SDB.Player.CurrentSong                                      'SDB.Player.CurrentSong
    Case 2
      Set objSongListiterator = SDB.Database.QuerySongs("AND Songs.ID=" & SampleID) 'SDB.Database.QuerySongs
    Case 3
      SQLString = "SELECT SongTitle FROM Songs WHERE Songs.ID = " & SampleID
      Set objSongStringiterator = SDB.Database.OpenSQL(SQLString)                    'SDB.Database.OpenSQL
    Case 4
      Set objSongList = SDB.SelectedSongList                                        'SDB.SelectedSongList
'      Set objSongList = SDB.CurrentSongList                                      'SDB.CurrentSongList
'      Set objSongList = SDB.AllVisibleSongList                                    'SDB.AllVisibleSongList
    Case Else
      SDB.MessageBox "Incorrect Select Method ", mtError, Array(mbOK)              'SDB.MessageBox
      Exit Sub
  End Select
'  For iCounter = 0 to objSongList.count - 1                                        'SelectMethod 4 SongLists
    While Not objSongListiterator.EOF                                              'SelectMethod 2
'    While Not objSongStringiterator.EOF                                              'SelectMethod 3
      Set objSongData = objSongListiterator.Item                                    'SelectMethod 2
      objSongList.Add(objSongData)                                                  'SelectMethod 2
'      Set objSongData = objSongList.Item(iCounter)                                  'SelectMethod 4
      StringTitle = objSongData.Title                                'SelectMethod 1, 2 and 4
      SDB.MessageBox "Value = '" & StringTitle & "'", mtError, Array(mbOK) 'SelectMethod 4 (2 and 3)
'      StringTitle = objSongStringiterator.StringByIndex(0)                  'SelectMethod 3
    objSongListiterator.Next                                                        'SelectMethod 2
'    objSongStringiterator.Next                                                        'SelectMethod 3
    Wend                                                                            'SelectMethod 2 and 3
'  Next                                                                              'SelectMethod 4
  Set objSongListiterator=Nothing                                                  'SelectMethod 2
'  Set objSongStringiterator=Nothing                                                  'SelectMethod 3
 
  SDB.MessageBox "Value = '" & StringTitle & "'", mtError, Array(mbOK)
 
'  objSongData.Title = StringNewTitle 'Commented Out For Safety      'SelectMethod 1, 2 and 4
'  objSonglist.UpdateAll                            'Commented Out For Safety      'UpdateAll
                        'SelectMethod 1, 2 and 4 Updates db and writes tags (if checked in options)
End Sub</source>

Latest revision as of 18:23, 20 April 2008

Instructions

  1. Copy the sample code into a text editor
  2. Replace highlighted terms with information from the items page in the Property Summary Table Title e.g.
    1. Value Name = Title
    2. Value Type = String
    3. Field Name = SongTitle
    4. Database Table = Songs
  3. Change the SelectMethod = 1 to a number corresponding to the select method required e.g.
    1. SelectMethod = 2 would use SQLQuery Method
  4. Comment all lines that DO NOT match the SelectMethod chosen by adding a single quote to the front of the line e.g. If SelectMethod was set as 3 all lines with 'SelectMethod not containing 2 would need to be commented out (or removed)
    1. ' For iCounter = 0 to objSongList.count - 1 'SelectMethod 4 SongLists
  5. Save the file as WikiSample.vbs in ...MediaMonkey\Scripts folder
  6. Edit the ...MediaMonkey\Scripts\Scripts.ini and add (copy/paste the section between '<-- Start ini code and '<--- End ini code) and save
  7. Start MM and select menu Tools --> Scripts --> WikiSample

Note: If Value Type = Object you will need to add the Member Name to the code e.g. ObjectAlbum = objSongData.Album.Member

Sample Code

'
' MediaMonkey Script
'
' NAME: WikiSample.vbs
'
' Template Author: MoDementia
' Time, DATE :  22:31, 09 April 2008
'
'Sample of Scripting Code Read and Write Method(s)
'A working script to show database results using various selection methods
'
'MediaMonkey\Scripts\Scripts.ini entry
'
'<-- Start ini code
'[WikiSample]                                                                       'Format of the Scripts.ini file
'Filename=WikiSample.vbs
'Procname=WikiSample
'Order=99
'DisplayName=WikiSample
'Description=Displays the raw database value of the MMWikipage item
'Language=VBScript
'ScriptType=0
'<-- End ini code

 Sub WikiSample
  Dim SelectMethod, SampleID, Value TypeNewValue Name

Dim SQLString 'SelectMethod 3

  Dim objSongList                                                                   'SelectMethod 2

  SelectMethod = 1
  ' SelectMethod NowPlaying = 1
  ' SelectMethod UseSQLQuery = 2

' SelectMethod UseSQL = 3

  ' SelectMethod SelectedSongs = 4

'   SampleID = 13123                                                                  'Usualy Set in another part of the script
'Random SampleID Code (Remove if SampleID known)
  Set iter = SDB.Database.OpenSQL("SELECT DISTINCT Songs.ID FROM Songs ORDER BY RANDOM() Limit 1")
  While Not iter.EOF
    SampleID = iter.StringByIndex(0)
  iter.Next
  Wend
'End of random SampleID code
  Value TypeNewValue Name = "Mamma Mia"
  Set objSongList = SDB.NewSongList                                                 'SelectMethod 2 and 3 SDB.NewSongList
  
  Select Case SelectMethod
    Case 1
      Set objSongData = SDB.Player.CurrentSong                                      'SDB.Player.CurrentSong
    Case 2
      Set objSongListiterator = SDB.Database.QuerySongs("AND Songs.ID=" & SampleID) 'SDB.Database.QuerySongs

Case 3 SQLString = "SELECT Field Name FROM Database Table WHERE Database Table.ID = " & SampleID Set objSongStringiterator = SDB.Database.OpenSQL(SQLString) 'SDB.Database.OpenSQL

    Case 4
      Set objSongList = SDB.SelectedSongList                                        'SDB.SelectedSongList
'       Set objSongList = SDB.CurrentSongList                                       'SDB.CurrentSongList
'       Set objSongList = SDB.AllVisibleSongList                                    'SDB.AllVisibleSongList
    Case Else
      SDB.MessageBox "Incorrect Select Method ", mtError, Array(mbOK)               'SDB.MessageBox
      Exit Sub
  End Select
  
  For iCounter = 0 to objSongList.count - 1                                         'SelectMethod 4 SongLists
    While Not objSongListiterator.EOF                                               'SelectMethod 2 Iterator
    While Not objSongStringiterator.EOF                                               'SelectMethod 3
      Set objSongData = objSongListiterator.Item                                    'SelectMethod 2
      objSongList.Add(objSongData)                                                  'SelectMethod 2
      Set objSongData = objSongList.Item(iCounter)                                  'SelectMethod 4
      Value TypeValue Name = objSongData.Value Name                                 'SelectMethod 1, 2 and 4
      SDB.MessageBox "Value = '" & Value TypeValue Name & "'", mtError, Array(mbOK) 'SelectMethod 4 (2 and 3)

Value TypeValue Name = objSongStringiterator.StringByIndex(0) 'SelectMethod 3

    objSongListiterator.Next                                                        'SelectMethod 2
    objSongStringiterator.Next                                                        'SelectMethod 3
    Wend                                                                            'SelectMethod 2 and 3
  Next                                                                              'SelectMethod 4
  Set objSongListiterator=Nothing                                                   'SelectMethod 2
  Set objSongStringiterator=Nothing                                                   'SelectMethod 3

  SDB.MessageBox "Value = '" & Value TypeValue Name & "'", mtError, Array(mbOK)

'  objSongData.Value Name = Value TypeNewValue Name 'Commented Out For Safety       'SelectMethod 1, 2 and 4
'  objSonglist.UpdateAll                            'Commented Out For Safety       'UpdateAll
                         'SelectMethod 1, 2 and 4 Updates db and writes tags (if checked in options)
End Sub

Converted Sample Method 2

'
' MediaMonkey Script
'
' NAME: WikiSample.vbs
'
' Template Author: MoDementia
' Time, DATE :  22:31, 09 April 2008
'
'Sample of Scripting Code Read and Write Method(s)
'A working script to show database results using various selection methods
'
'MediaMonkey\Scripts\Scripts.ini entry
'
'<-- Start ini code
'[WikiSample]                                                                       'Format of the Scripts.ini file
'Filename=WikiSample.vbs
'Procname=WikiSample
'Order=99
'DisplayName=WikiSample
'Description=Displays the raw database value of the MMWikipage item
'Language=VBScript
'ScriptType=0
'<-- End ini code

 Sub WikiSample
  Dim SelectMethod, SampleID, StringNewTitle
'   Dim SQLString                                                                     'SelectMethod 3
  Dim objSongList                                                                   'SelectMethod 2

  SelectMethod = 2
  ' SelectMethod NowPlaying = 1
  ' SelectMethod UseSQLQuery = 2
  ' SelectMethod UseSQL = 3
  ' SelectMethod SelectedSongs = 4
 
'   SampleID = 13123                                                                   'Usualy Set in another part of the script
'Random SampleID Code (Remove if SampleID known)
  Set iter = SDB.Database.OpenSQL("SELECT DISTINCT Songs.ID FROM Songs ORDER BY RANDOM() Limit 1")
  While Not iter.EOF
    SampleID = iter.StringByIndex(0)
  iter.Next
  Wend
  Set iter=Nothing
'End of random SampleID code
  StringNewTitle = "Mamma Mia"
  Set objSongList = SDB.NewSongList                                                 'SelectMethod 2 and 3 SDB.NewSongList
 
  Select Case SelectMethod
    Case 1
      Set objSongData = SDB.Player.CurrentSong                                      'SDB.Player.CurrentSong
    Case 2
      Set objSongListiterator = SDB.Database.QuerySongs("AND Songs.ID=" & SampleID) 'SDB.Database.QuerySongs
    Case 3
      SQLString = "SELECT SongTitle FROM Songs WHERE Songs.ID = " & SampleID
      Set objSongStringiterator = SDB.Database.OpenSQL(SQLString)                     'SDB.Database.OpenSQL
    Case 4
      Set objSongList = SDB.SelectedSongList                                        'SDB.SelectedSongList
'       Set objSongList = SDB.CurrentSongList                                       'SDB.CurrentSongList
'       Set objSongList = SDB.AllVisibleSongList                                    'SDB.AllVisibleSongList
    Case Else
      SDB.MessageBox "Incorrect Select Method ", mtError, Array(mbOK)               'SDB.MessageBox
      Exit Sub
  End Select
 
'   For iCounter = 0 to objSongList.count - 1                                         'SelectMethod 4 SongLists
    While Not objSongListiterator.EOF                                               'SelectMethod 2
'     While Not objSongStringiterator.EOF                                               'SelectMethod 3
      Set objSongData = objSongListiterator.Item                                    'SelectMethod 2
      objSongList.Add(objSongData)                                                  'SelectMethod 2
'       Set objSongData = objSongList.Item(iCounter)                                  'SelectMethod 4
      StringTitle = objSongData.Title                                 'SelectMethod 1, 2 and 4
      SDB.MessageBox "Value = '" & StringTitle & "'", mtError, Array(mbOK) 'SelectMethod 4 (2 and 3)
'       StringTitle = objSongStringiterator.StringByIndex(0)                   'SelectMethod 3
    objSongListiterator.Next                                                        'SelectMethod 2
'     objSongStringiterator.Next                                                        'SelectMethod 3
    Wend                                                                            'SelectMethod 2 and 3
'   Next                                                                              'SelectMethod 4
  Set objSongListiterator=Nothing                                                   'SelectMethod 2
'   Set objSongStringiterator=Nothing                                                   'SelectMethod 3
  
  SDB.MessageBox "Value = '" & StringTitle & "'", mtError, Array(mbOK)

'  objSongData.Title = StringNewTitle 'Commented Out For Safety       'SelectMethod 1, 2 and 4
'  objSonglist.UpdateAll                            'Commented Out For Safety       'UpdateAll
                         'SelectMethod 1, 2 and 4 Updates db and writes tags (if checked in options)
End Sub