PeterSwiss Posted January 24, 2006 Share Posted January 24, 2006 How Do I, in VBScript, create a Collection? such that, say, c("x")=1, v=c("x"), and FOR EACH y in c do work, as these statements do for built-in collections. I searched the internet without success. Thanks for help. Peter Link to comment Share on other sites More sharing options...
Methos Posted January 27, 2006 Share Posted January 27, 2006 I think this is what you are looking for, but not totally sure. Check the helpfile for the ObjCreate function. Here is a snippet from there. $oShell = ObjCreate("shell.application") ; Get the Windows Shell Object $oShellWindows=$oShell.windows ; Get the collection of open shell Windows if Isobj($oShellWindows) then $string="" ; String for displaying purposes for $Window in $oShellWindows ; Count all existing shell windows $String = $String & $window.LocationName & @CRLF next Msgbox(0,"Shell Windows","You have the following shell windows:" & @CRLF & @CRLF & $String); endif exit ; Example 2 ; ; Open the MediaPlayer on a REMOTE computer $oRemoteMedia = ObjCreate("MediaPlayer.MediaPlayer.1","name-of-remote-computer") If not @error then Msgbox(0,"Remote ObjCreate Test","ObjCreate() of a remote Mediaplayer Object successfull !") $oRemoteMedia.Open("c:\windows\media\Windows XP Startup.wav") ; Play sound if file is present Else Msgbox(0,"Remote ObjCreate Test","Failed to open remote Object. Error code: " & hex(@error,8)) Endif To me, that looks like what you are asking for. Link to comment Share on other sites More sharing options...
PeterSwiss Posted January 27, 2006 Author Share Posted January 27, 2006 I think this is what you are looking for, but not totally sure. Check the helpfile for the ObjCreate function. Here is a snippet from there.To me, that looks like what you are asking for. Methos thanks for answering, but I was looking not for a list of windows, or mediaplayer, but for "Collections" in general. I found it myself. First, it needs to be a Dictionary. Second, the assignment statement for objects needs, in VBScript, always a "Set". Third it is not obligatory to use dictionarys Add method, one can write subscripts. As for example:Dim cSet c = CreateObject("Scripting.Dictionary")c("a") = 1c("b") = 2c.Add "d", 4 'generate <br> c(x)=valuefor each x in c response.write "<br> c(" & x & ")=" c(x) nextThat's all it takes. Link to comment Share on other sites More sharing options...
doudou Posted February 20, 2006 Share Posted February 20, 2006 (edited) Methos thanks for answering, but I was looking not for a list of windows, or mediaplayer, but for "Collections" in general. Well Peter, it's almost as easy in AutoIt as in VB: $c = ObjCreate("Scripting.Dictionary") $c.Item("a") = 1 MsgBox(0, "Dictionary", "Item a = " & c.Item("a)) Different is only that you don't need 'set' keyword for object assignments and there's no support for default properties in AutoIt, i.e. you can't use what you call 'subscripts' like c("a"), however c.Item("a") is exactly what VB does internally so it's equivalent. Edited May 15, 2006 by Larry UDFS & Apps: Spoiler DDEML.au3 - DDE Client + ServerLocalization.au3 - localize your scriptsTLI.au3 - type information on COM objects (TLBINF emulation)TLBAutoEnum.au3 - auto-import of COM constants (enums)AU3Automation - export AU3 scripts via COM interfacesTypeLibInspector - OleView was yesterday Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCEĀ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now