VBScript 中的 UDT:“错误:预期标识符”
我习惯了 ClassicVB/VB.Net,但不习惯 VBScript,并且从应用程序调用下面的脚本时遇到错误:
# $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
我已经在 google 上搜索了示例,但没有找到上述问题。
谢谢。
编辑:通过使用哈希/字典解决问题:
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有用户定义的结构在 vb 脚本中。
有用户定义的类,然而。
There are no user-defined structures in vbscript.
There are user-defined classes, however.