Template:Example Code: Difference between revisions

From MediaMonkey Wiki
Jump to navigation Jump to search
No edit summary
(Added Category Template)
Line 75: Line 75:
                           '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
  End Sub
<noinclude>[[Category:Template]]</noinclude>

Revision as of 05:22, 9 April 2008

'
' MediaMonkey Script
'
' NAME: WikiSample.vbs
'
' Template Author: MoDementia
' Generated by MMWiki page Example Code
' Time, DATE :  11:47, 28 March 2024
'
'Sample of Scripting Code for inclusion into MMWiki pages
'A working script to show database results using various selection methods
'
'MediaMonkey\Scripts\Scripts.in entry
'
'[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


Sub WikiSample

  Dim SelectMethod, SampleID, -New-

Dim SQLString 'SelectMethod 3

  Dim objSongList                                                          'SelectMethod 2

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

' SelectMethod UseSQL = 3

  ' SelectMethod SelectedSongs = 4
  
  SampleID = 13123
  -New- = "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 - FROM - WHERE -.ID = " & SampleID Set objSongListiterator = 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 and 3 Iterator
      Set objSongData = objSongListiterator.Item                           'SelectMethod 2
      objSongList.Add(objSongData)                                         'SelectMethod 2
      Set objSongData = objSongList.Item(iCounter)                         'SelectMethod 4
      -- = objSongData.-                                      'SelectMethod 1, 2 and 4
      SDB.MessageBox "Value = '" & -- & "'", mtError, Array(mbOK) 'SelectMethod 4 (2 and 3)

-- = 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 = '" & -- & "'", mtError, Array(mbOK)

'  objSongData.- = -New- '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