DO11: Scripting, vector properties

Running Beta10, and not sure what I'm doing wrong, but checking for the vector being empty fails:

[code]Option Explicit
' Called by Directory Opus to initialize the script
Function OnInit(ByRef initData)

DOpus.Output("Initializing...")
' Provide basic information about the Script
initData.name = "OnBeforeFolderChange_vbtest"
initData.desc = "Adds the 'OnBeforeFolderChange_vbtest' event handler to Directory Opus."
initData.copyright = "(c) 2014 steje"
initData.version = "v1.0.0 (vb)"
initData.default_enable = True

'////////////////////////////////////////////////
' Set DEBUG flag below to true in order to enable logging messages to the Opus Output Window
initData.config.DEBUG = True
'////////////////////////////////////////////////
' Create a ScriptConfig property of type VT_BSTR
initData.config.strScriptVT_BSTR = "VT_BSTR"
'////////////////////////////////////////////////
' Create a ScriptConfig property of type VT_I4
initData.config.iScriptVT_I4 = 255
'////////////////////////////////////////////////
' Create a ScriptConfig property of type VT_BOOL
initData.config.bScriptVT_BOOL = False
'////////////////////////////////////////////////
' Create a ScriptConfig property of type VT_VECTOR / VB TypeName() will return type : Variant
initData.config.objScriptVT_VECTOR = DOpus.NewVector("")

End Function

' Called before a folder is opened
Function OnBeforeFolderChange(ByRef beforeFolderChangeData)

Dim message
message = ""
Const vbQuote = """"
Dim STRING
STRING = "VT_BSTR"

logMsg("")
logMsg("------------Begin------------")

'////////////////////////////////////////////////
' Test the objScriptVT_VECTOR ScriptConfig property
Dim i, x, objScriptVT_VECTOR_type, objLinkedTabList_type

If (Script.config.objScriptVT_VECTOR.empty) Then
logMsg("objScriptVT_VECTOR is empty... exit")
Exit Function
End If

logMsg("")
message = "ScriptConfig property objScriptVT_VECTOR "
objScriptVT_VECTOR_type = TypeName(Script.config.objScriptVT_VECTOR)
logMsg(message & "is of type: " & objScriptVT_VECTOR_type)
If Not (objScriptVT_VECTOR_type = "unknown") Then
i = 0
For Each x in (Script.config.objScriptVT_VECTOR)
logMsg(message & "values are set to: [" & i & "]: " & x)
i = i + 1
Next
End If

'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

logMsg("")
logMsg("------------End------------" & vbCrLf)

End Function

' Subroutine to allow toggling of the global VT_BOOL variable to control whether logging is performed or not
Sub logMsg(message)

If (Script.config.DEBUG) Then DOpus.Output(message)

End Sub[/code]
...just even looking without testing, shouldn't the If (Script.config.objScriptVT_VECTOR.empty) check be true here? If you're inclined to say its the ("") assignment, well... setting a size of (0) or even just () produces an error when I test the vector in that If check:

Object required: 'Script.config.objScriptVT_VECTOR' (0x800a01a8)

If you initialise it with Vector("") that's creating a vector with one item (an empty string), so the vector itself is not empty - this is correct.

However there is a bug in that a truly empty vector is not properly returned to the script when it's triggered - instead the variable will be passed as VT_EMPTY.
We'll fix this in the next update. In the meantime you can workaround it by testing the variable type itself (e.g. by using the IsEmpty() function).

Hmmm... but if I initialize (in this case a Script.Config array) with a size of 0, the Configure dialog for that Config property no longer treats it like an array - but rather allows only a single string entry.

So I have to initialize it to "" in order to allow users to make multiple entries like in an array. But then I don't see a good way to check early on in script execution whether or not there are any entries in that property (IsEmpty or something) to decide to continue on processing or not.

That'll be fixed in the next version, in the meantime you could just check if it contains a single empty string.

Ok thanks alot... I had tried checking for "" but it had thrown an error... I must have goofed something up. Will try again.

Yeah, ok:

' Check if the LinkedTabList is empty and if so - nothing to do, exit... If (Script.config.objLinkedTabList.count = 1) And (Script.config.objLinkedTabList(0) = "") Then logMsg("LinkedTabList is empty... exit") Exit Function End If