View Issue Details

IDProjectCategoryView StatusLast Update
0004101MMW v4Framework: Scripts/Extensionspublic2009-01-07 23:40
Reporterpeke Assigned To 
PriorityurgentSeveritymajorReproducibilityalways
Status closedResolutionno change required 
Summary0004101: SDB.Objects not available in OnStartup
DescriptionWhen trying to use SDB.Objects in Sub OnStartup MM rises Runtime Error 424 Object required 'SDB.Objects'
Additional InformationExample Script Code:
Sub OnStartup
  Dim MyWindow
  ind = SDB.UI.AddOptionSheet("test",Script.ScriptPath,"InitSheet","SaveSheet",0)
  MyWindow = ind
  If SDB.Objects("MyWindowRef") Is Nothing Then ' If the object isn't in collection yet...
    Set SDB.Objects("MyWindowRef") = MyWindow ' ... add it to the collection (using Set for objects)...
  End If
End Sub
TagsNo tags attached.
Fixed in build

Activities

jiri

2009-01-07 12:44

administrator   ~0016048

This isn't a bug in MM, the script is incorrect. E.g. this works fine:

Sub OnStartup
  Dim MyWindow
  ind = SDB.UI.AddOptionSheet("test",Script.ScriptPath,"InitSheet","SaveSheet",0)
  Set MyWindow = Nothing
  If SDB.Objects("MyWindowRef") Is Nothing Then ' If the object isn't in collection yet...
    Set SDB.Objects("MyWindowRef") = MyWindow ' ... add it to the collection (using Set for objects)...
  End If
End Sub

peke

2009-01-07 13:44

developer   ~0016051

Last edited: 2009-01-07 13:45

That code you wrote do not save Option sheet to collection Set for Objects and that was the intention, but it looks that this is not available at all within MM,

See this code:
Sub OnStartup
  Dim MyWindow
  Set MyWindow = Nothing
  If SDB.Objects("MyWindowRef") Is Nothing Then ' If the object isn't in collection yet...
    Set SDB.Objects("MyWindowRef") = MyWindow ' ... add it to the collection (using Set for objects)...
  Else
    ind = SDB.UI.AddOptionSheet("test",Script.ScriptPath,"InitSheet","SaveSheet",0)
    MyWindow = ind
    Set SDB.Objects("MyWindowRef") = MyWindow ' ... add it to the collection
  End If
End Sub

jiri

2009-01-07 13:49

administrator   ~0016052

No, as documented in Wiki, 'ind' is an integer and so it can't be stored as an Object, that's VB thing, not MM thing.

peke

2009-01-07 23:40

developer   ~0016068

I know that, thx for reminding me I Have found the workaround.

Thing I wanted to archive is that I want save option sheet created in script1.vbs and then access it from Script2.vbs to create additional Sub Sheet using MediaMonkey.ini it could be archived by saving ind value in ini and then use it as ParentID for Script2 (eg. Last.fm services -> last.fm DJ (As services subsheet)?

Something like this works:
Script1.vbs:
ind = SDB.UI.AddOptionSheet("test", SDB.ScriptsPath,"InitSheet","SaveSheet",0)
SDB.IniFile.IntValue("Custom Option Sheets", "RootSheetID") = ind

Script2.vbs:
ind = SDB.UI.AddOptionSheet("test", SDB.ScriptsPath,"InitSheet","SaveSheet", SDB.IniFile.IntValue("Custom Option Sheets", "RootSheetID"))

Closing the issue.