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

From MediaMonkey Wiki
Jump to navigation Jump to search
No edit summary
(Starting Again)
Line 1: Line 1:
<div><source lang="vb">
'
'
' MediaMonkey Script
' MediaMonkey Script
'
'
' NAME: WikiSample.vbs
' NAME: WikiSample.vbs
'
'
' Template Author: MoDementia
' Template Author: MoDementia
' Generated by MMWiki page {{PAGENAME}}
' Time, DATE :  22:31, 09 April 2008
' Time, DATE :  {{CURRENTTIME}}, {{CURRENTDAY2}} {{CURRENTMONTHNAME}} {{CURRENTYEAR}}
'
'
'Sample of Scripting Code Read and Write Method(s)
'Sample of Scripting Code for inclusion into MMWiki pages
'A working script to show database results using various selection methods
'A working script to show database results using various selection methods
'
'
'MediaMonkey\Scripts\Scripts.in entry
'MediaMonkey\Scripts\Scripts.in entry
'
'
'[WikiSample]                                                            'Format of the Scripts.ini file
'[WikiSample]                                                            '[[Introduction_to_scripting#Format_of_the_Scripts.ini_file|Format of the Scripts.ini file]]
'Filename=WikiSample.vbs
'Filename=WikiSample.vbs
'Procname=WikiSample
'Procname=WikiSample
'Order=99
'Order=99
'DisplayName=WikiSample
'DisplayName=WikiSample
'Description=Displays the raw database value of the MMWikipage item
'Description=Displays the raw database value of the MMWikipage item
'Language=VBScript
'Language=VBScript
'ScriptType=0
'ScriptType=0
 
 
Sub WikiSample
Sub WikiSample
 
<span style="color: #b1b100;">Sub</span>
  Dim SelectMethod, SampleID, ValueTypeNewValueName
  Dim SelectMethod, SampleID, {{{3|-}}}New{{{2|-}}}
   Dim SQLString                                                            'SelectMethod 3
{{#ifeq:{{{3|-}}}|Object| |   Dim SQLString                                                            'SelectMethod 3}}
  Dim objSongList                                                          'SelectMethod 2
  Dim objSongList                                                          'SelectMethod 2
 
  SelectMethod = 1
  SelectMethod = 1
  ' SelectMethod NowPlaying = 1
  ' SelectMethod NowPlaying = 1
  ' SelectMethod UseSQLQuery = 2
  ' SelectMethod UseSQLQuery = 2
   ' SelectMethod UseSQL = 3
{{#ifeq:{{{3|-}}}|Object| |   ' SelectMethod UseSQL = 3}}
  ' SelectMethod SelectedSongs = 4
  ' SelectMethod SelectedSongs = 4
 
 
  SampleID = 13123
  SampleID = 13123
 
  {{{3|-}}}New{{{2|-}}} = "Mamma Mia"
  ValueTypeNewValueName = "Mamma Mia"
  Set objSongList = SDB.NewSongList                                        'SelectMethod 2 and 3 [[ISDBApplication::NewSongList|SDB.NewSongList]]
 
 
  Set objSongList = SDB.NewSongList                                        'SelectMethod 2 and 3 SDB.NewSongList
  Select Case SelectMethod
 
    Case 1
  Select Case SelectMethod
      Set objSongData = SDB.Player.CurrentSong                            '[[ISDBPlayer::CurrentSong|SDB.Player.CurrentSong]]
    Case 1
    Case 2
      Set objSongData = SDB.Player.CurrentSong                            'SDB.Player.CurrentSong
      Set objSongListiterator = SDB.Database.QuerySongs("AND Songs.ID=" & SampleID) '[[ISDBDatabase::QuerySongs|SDB.Database.QuerySongs]]
    Case 2
{{#ifeq:{{{3|-}}}|Object| |     Case 3}}
      Set objSongListiterator = SDB.Database.QuerySongs("AND DatabaseTable.ID=" & SampleID) 'SDB.Database.QuerySongs
{{#ifeq:{{{3|-}}}|Object| |       SQLString = "SELECT {{{5|-}}} FROM {{{4|-}}} WHERE {{{4|-}}}.ID = " & SampleID}}
     Case 3
{{#ifeq:{{{3|-}}}|Object| |       Set objSongListiterator = SDB.Database.OpenSQL(SQLString)            '[[ISDBDatabase::OpenSQL|SDB.Database.OpenSQL]]}}
     
    Case 4
       SQLString = "SELECT FieldName FROM DatabaseTable WHERE DatabaseTable.ID = " & SampleID
      Set objSongList = SDB.SelectedSongList                              '[[ISDBApplication::SelectedSongList|SDB.SelectedSongList]]
     
'      Set objSongList = SDB.CurrentSongList                              '[[ISDBApplication::CurrentSongList|SDB.CurrentSongList]]
       Set objSongListiterator = SDB.Database.OpenSQL(SQLString)            'SDB.Database.OpenSQL
'      Set objSongList = SDB.AllVisibleSongList                          '[[ISDBApplication::AllVisibleSongList|SDB.AllVisibleSongList]]
    Case 4
    Case Else
      Set objSongList = SDB.SelectedSongList                              'SDB.SelectedSongList
      SDB.MessageBox "Incorrect Select Method ", mtError, Array(mbOK)      '[[ISDBApplication::MessageBox|SDB.MessageBox]]
'      Set objSongList = SDB.CurrentSongList                              'SDB.CurrentSongList
      Exit Sub
'      Set objSongList = SDB.AllVisibleSongList                          'SDB.AllVisibleSongList
  End Select
    Case Else
 
      SDB.MessageBox "Incorrect Select Method ", mtError, Array(mbOK)      'SDB.MessageBox
  For iCounter = 0 to objSongList.count - 1                                'SelectMethod 4 [[SDBSongList|SongLists]]
      Exit Sub
    While Not objSongListiterator.EOF                                      'SelectMethod 2 and 3 [[SDBDBIterator|Iterator]]
  End Select
      Set objSongData = objSongListiterator.Item                          'SelectMethod 2
 
      objSongList.Add(objSongData)                                        'SelectMethod 2
  For iCounter = 0 to objSongList.count - 1                                'SelectMethod 4 SongLists
      Set objSongData = objSongList.Item(iCounter)                        'SelectMethod 4
    While Not objSongListiterator.EOF                                      'SelectMethod 2 and 3 Iterator
      {{{3|-}}}{{{2|-}}} = objSongData.{{{2|-}}}{{#ifeq:{{{3|-}}}|Object|.Member}}                                      'SelectMethod 1, 2 and 4
      Set objSongData = objSongListiterator.Item                          'SelectMethod 2
      SDB.MessageBox "Value = '" & {{{3|-}}}{{{2|-}}} & "'", mtError, Array(mbOK) 'SelectMethod 4 (2 and 3)
      objSongList.Add(objSongData)                                        'SelectMethod 2
{{#ifeq:{{{3|-}}}|Object| |       {{{3|-}}}{{{2|-}}} = objSongListiterator.StringByIndex(0)                  'SelectMethod 3}}
      Set objSongData = objSongList.Item(iCounter)                        'SelectMethod 4
    objSongListiterator.Next                                              'SelectMethod 2 and 3
     
    Wend                                                                  'SelectMethod 2 and 3
      ValueTypeValueName = objSongData.ValueName                          'SelectMethod 1, 2 and 4
  Next                                                                    'SelectMethod 4
     
  Set objSongListiterator=Nothing                                          'SelectMethod 2 and 3
      SDB.MessageBox "Value = '" & ValueTypeValueName & "'", mtError, Array(mbOK) 'SelectMethod 4 (2 and 3)
        
  SDB.MessageBox "Value = '" & {{{3|-}}}{{{2|-}}} & "'", mtError, Array(mbOK)
      ValueTypeValueName = objSongListiterator.StringByIndex(0)                  'SelectMethod 3
   
'  objSongData.{{{2|-}}}{{#ifeq:{{{3|-}}}|Object|.Member}} = {{{3|-}}}New{{{2|-}}} 'Commented Out For Safety 'SelectMethod 1, 2 and 4
      objSongListiterator.Next                                              'SelectMethod 2 and 3
'  objSonglist.UpdateAll              'Commented Out For Safety            '[[SDBSongData|UpdateAll]]
    Wend                                                                  'SelectMethod 2 and 3
                          'SelectMethod 1, 2 and 4 Updates db and writes tags (if checked in options)
  Next                                                                    'SelectMethod 4
End Sub<noinclude>[[Category:Template]]</noinclude>
  Set objSongListiterator=Nothing                                          'SelectMethod 2 and 3
 
  SDB.MessageBox "Value = '" & ValueTypeValueName & "'", mtError, Array(mbOK)
 
'  objSongData.Title = ValueTypeNewValueName  '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>
 
<source lang="vb">
'
' MediaMonkey Script
'
' NAME: WikiSample.vbs
'
' Template Author: MoDementia
' Generated by MMWiki page ISDBSongData::Album
' Time, DATE :  22:31, 09 April 2008
'
'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, ObjectNewAlbum
 
  Dim objSongList                                                          'SelectMethod 2
 
  SelectMethod = 1
  ' SelectMethod NowPlaying = 1
  ' SelectMethod UseSQLQuery = 2
 
  ' SelectMethod SelectedSongs = 4
 
  SampleID = 13123
  ObjectNewAlbum = "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 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
      ObjectAlbum = objSongData.Album.Member                                      'SelectMethod 1, 2 and 4
      SDB.MessageBox "Value = '" & ObjectAlbum & "'", mtError, Array(mbOK) 'SelectMethod 4 (2 and 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 = '" & ObjectAlbum & "'", mtError, Array(mbOK)
 
'  objSongData.Album.Member = ObjectNewAlbum '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></div>
<!---Line=14px Char=7px--->
<div id="Dim1.1" style="background:#CCFFCC none repeat scroll 0%; position: relative; left: 250px; top: -1948px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Type</em></div></div>
<div id="Dim1.2" style="background:#FFCC99 none repeat scroll 0%; position: relative; left: 350px; top: -1964px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Name</em></div></div>
<div id="Var2.1" style="background:#CCFFCC none repeat scroll 0%; position: relative; left: 27px; top: -1813px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Type</em></div></div>
<div id="Var2.2" style="background:#FFCC99 none repeat scroll 0%; position: relative; left: 127px; top: -1829px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Name</em></div></div>
<div id="Case3.1" style="background:#CC99FF none repeat scroll 0%; position: relative; left: 218px; top: -1692px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Field Name</em></div></div>
<div id="Case3.2" style="background:#CC99FF none repeat scroll 0%; position: relative; left: 342px; top: -1708px; width: 105px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Database Table</em></div></div>
<div id="Case3.2" style="background:#CC99FF none repeat scroll 0%; position: relative; left: 503px; top: -1724px; width: 105px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Database Table</em></div></div>
<div id="Loop6.1" style="background:#CCFFCC none repeat scroll 0%; position: relative; left: 60px; top: -1490px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Type</em></div></div>
<div id="Loop6.2" style="background:#FFCC99 none repeat scroll 0%; position: relative; left: 135px; top: -1506px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Name</em></div></div>
<div id="Loop6.3" style="background:#FFCC99 none repeat scroll 0%; position: relative; left: 325px; top: -1522px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Name</em></div></div>
<div id="Loop7.1" style="background:#CCFFCC none repeat scroll 0%; position: relative; left: 295px; top: -1510px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Type</em></div></div>
<div id="Loop7.2" style="background:#FFCC99 none repeat scroll 0%; position: relative; left: 370px; top: -1526px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Name</em></div></div>
<div id="Loop8.1" style="background:#CCFFCC none repeat scroll 0%; position: relative; left: 59px; top: -1514px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Type</em></div></div>
<div id="Loop8.2" style="background:#FFCC99 none repeat scroll 0%; position: relative; left: 134px; top: -1530px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Name</em></div></div>
<div id="Write2.1" style="background:#CCFFCC none repeat scroll 0%; position: relative; left: 259px; top: -1449px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Type</em></div></div>
<div id="Write2.2" style="background:#FFCC99 none repeat scroll 0%; position: relative; left: 334px; top: -1465px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Name</em></div></div>
<div id="Dim1.1" style="background:#CCFFCC none repeat scroll 0%; position: relative; left: 195px; top: -1452px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Type</em></div></div>
<div id="Dim1.2" style="background:#FFCC99 none repeat scroll 0%; position: relative; left: 295px; top: -1468px; width: 75px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Value Name</em></div></div>
<div id="Case2.1" style="background:#CC99FF none repeat scroll 0%; position: relative; left: 502px; top: -1957px; width: 105px; height: 16px; z-index: 1; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: middle;" ><div align="center"><em>Database Table</em></div></div>

Revision as of 05:51, 10 April 2008

'
' MediaMonkey Script
'
' NAME: WikiSample.vbs
'
' Template Author: MoDementia
' Generated by MMWiki page Sample Read and Write Method(s)
' Time, DATE :  12:13, 21 June 2025
'
'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
Sub
  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