Search code examples
vbscriptuser-defined-types

UDT in VBScript: "Error: Expected identifier"


I'm used to ClassicVB/VB.Net but not VBScript, and I'm getting an error when calling the script below from an application:

# $language = "VBScript"
# $interface = "1.0"

'Microsoft VBScript compilation error
'Error: Expected identifier
Public Type MyType
    Caption As String
    Dir As String
End Type

Sub Main
    'Whatever
End Sub

I've googled for samples, but didn't find what's wrong with the above.

Thank you.


Edit: Problem solved by using a hash/dictionary instead:

Set hash = CreateObject ("Scripting.Dictionary")

hash.add "MyDir", "cd /usr/src/mydir"
hash.add "Linux", "cd /usr/src/linux"

keys = hash.Keys
for index = 0 to hash.Count - 1
    Set tab = crt.session.ConnectInTab("/s 192.168.0.3")
    tab.Caption = Keys(index)
    Set tabscreen = tab.Screen
    tabscreen.Send hash.item(Keys(index)) & vbcr
Next

Solution

  • There are no user-defined structures in vbscript.

    There are user-defined classes, however.