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

From MediaMonkey Wiki
Jump to navigation Jump to search
No edit summary
 
(Almost there saving in case...)
Line 1: Line 1:
<!---Line=14px Char=7px--->
<div id="Dim1.1" style="background:#CCFFCC none repeat scroll 0%; position: absolute; left: 261px; top: 500px; 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: absolute; left: 363px; top: 500px; 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: absolute; left: 39px; top: 668px; 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: absolute; left: 139px; top: 668px; 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: absolute; left: 230px; top: 822px; 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: absolute; left: 350px; top: 822px; width: 100px; 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: absolute; left: 500px; top: 822px; width: 97px; 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: absolute; left: 70px; top: 1074px; 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: absolute; left: 145px; top: 1074px; 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: absolute; left: 335px; top: 1074px; 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: absolute; left: 307px; top: 1102px; 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: absolute; left: 382px; top: 1102px; 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: absolute; left: 70px; top: 1130px; 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: absolute; left: 145px; top: 1130px; 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>
<source lang="vb">
<source lang="vb">
'
'
Line 25: Line 40:
Sub WikiSample
Sub WikiSample


   Dim SelectMethod, SampleID, StringNewTitle
   Dim SelectMethod, SampleID, String  NewTitle
   Dim SQLString                                                            'SelectMethod 3
   Dim SQLString                                                            'SelectMethod 3
   Dim objSongList                                                          'SelectMethod 2
   Dim objSongList                                                          'SelectMethod 2
Line 36: Line 51:
    
    
   SampleID = 13123
   SampleID = 13123
   StringNewTitle = "Mamma Mia"
    
  String  NewTitle      = "Mamma Mia"
 
   Set objSongList = SDB.NewSongList                                        'SelectMethod 2 and 3 SDB.NewSongList
   Set objSongList = SDB.NewSongList                                        'SelectMethod 2 and 3 SDB.NewSongList
    
    
Line 45: Line 62:
       Set objSongListiterator = SDB.Database.QuerySongs("AND Songs.ID=" & SampleID) 'SDB.Database.QuerySongs
       Set objSongListiterator = SDB.Database.QuerySongs("AND Songs.ID=" & SampleID) 'SDB.Database.QuerySongs
     Case 3
     Case 3
       SQLString = "SELECT SongTitle FROM Songs WHERE Songs.ID = " & SampleID
     
       SQLString = "SELECT SongTitle FROM       Songs WHERE Songs     .ID = " & SampleID
     
       Set objSongListiterator = SDB.Database.OpenSQL(SQLString)            'SDB.Database.OpenSQL
       Set objSongListiterator = SDB.Database.OpenSQL(SQLString)            'SDB.Database.OpenSQL
     Case 4
     Case 4
Line 61: Line 80:
       objSongList.Add(objSongData)                                        'SelectMethod 2
       objSongList.Add(objSongData)                                        'SelectMethod 2
       Set objSongData = objSongList.Item(iCounter)                        'SelectMethod 4
       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       = objSongData.Title                                      'SelectMethod 1, 2 and 4
       StringTitle = objSongListiterator.StringByIndex(0)                  'SelectMethod 3
     
     objSongListiterator.Next                                              'SelectMethod 2 and 3
       SDB.MessageBox "Value = '" & StringTitle         & "'", mtError, Array(mbOK) 'SelectMethod 4 (2 and 3)
     
       StringTitle       = objSongListiterator.StringByIndex(0)                  'SelectMethod 3
      
      objSongListiterator.Next                                              'SelectMethod 2 and 3
     Wend                                                                  'SelectMethod 2 and 3
     Wend                                                                  'SelectMethod 2 and 3
   Next                                                                    'SelectMethod 4
   Next                                                                    'SelectMethod 4
Line 72: Line 95:


'  objSongData.Title = StringNewTitle 'Commented Out For Safety 'SelectMethod 1, 2 and 4
'  objSongData.Title = StringNewTitle 'Commented Out For Safety 'SelectMethod 1, 2 and 4
'  objSonglist.UpdateAll              'Commented Out For Safety            'UpdateAll
'  objSonglist.UpdateAll              'Commented Out For Safety            '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)

Revision as of 01:22, 10 April 2008

Value Type
Value Name
Value Type
Value Name
Field Name
Database Table
Database Table
Value Type
Value Name
Value Name
Value Type
Value Name
Value Type
Value Name
'
' MediaMonkey Script
'
' NAME: WikiSample.vbs
'
' Template Author: MoDementia
' 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, String   NewTitle
  Dim SQLString                                                            'SelectMethod 3
  Dim objSongList                                                          'SelectMethod 2

  SelectMethod = 1
  ' SelectMethod NowPlaying = 1
  ' SelectMethod UseSQLQuery = 2
  ' SelectMethod UseSQL = 3
  ' SelectMethod SelectedSongs = 4
  
  SampleID = 13123
  
  String   NewTitle      = "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 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
      
      StringTitle        = objSongData.Title                                      'SelectMethod 1, 2 and 4
      
      SDB.MessageBox "Value = '" & StringTitle         & "'", mtError, Array(mbOK) 'SelectMethod 4 (2 and 3)
      
      StringTitle        = 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 = '" & 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
'
' 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