WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: stanl on December 09, 2018, 08:16:46 AM

Title: WIN10 Collection Issues
Post by: stanl on December 09, 2018, 08:16:46 AM
My Win10 has Office 2019 and Visual Studio 2017 Community [updated], and I assume I have the same collection objects as with Win 7.  The following now gives an invalid COM Object


Code (WINBATCH[font=verdana) Select
]
d = CreateObject("VBA.Collection")
d.Add( "Athens" )
d.Add( "Belgrade" )
d.Add( "Cairo" )


[/font]But I can initialize

Code (WINBATCH) Select


d = CreateObject("Scripting.Dictionary")
d.Add( "a", "Athens" )
d.Add( "b", "Belgrade" )
d.Add( "c", "Cairo" )
Which errors with k = d.Keys(i) is NOT a Collection

Code (WINBATCH) Select

For i= 0 to (n - 1)
   k = d.Keys(i)
   t = d.items(i)
   message( "Item %t%","key %k%")
Next
[code]


Basically just checking on a few script snippets that worked in Win 7 using COM Objects.[/size][/font]

Title: Re: WIN10 Collection Issues
Post by: stanl on December 09, 2018, 08:48:25 AM
I hate stumbling on something that works after posting... this worked.


Code (WINBATCH) Select


ForEach k in d.Keys
   message(k,d.item(k))
Next
Title: Re: WIN10 Collection Issues
Post by: td on December 09, 2018, 08:50:26 AM
Or

Code (winbatch) Select
a = d.keys()
for i = 0 to d.count - 1
   k = a[i]
next
Title: Re: WIN10 Collection Issues
Post by: td on December 09, 2018, 08:54:18 AM
Or just use WIL maps.
Title: Re: WIN10 Collection Issues
Post by: stanl on December 09, 2018, 09:21:17 AM
Thanks. I'm really more interested in not being able to initialize vba.collection - it exists in my Excel 2019 Object Inspector and the references are correct, but even using it in an excel macro I get the 429 error. My AccessDatabase Engine is for 2016, I had 2010 but had issues scripting with the ACE.OLEDB provider. There is also a Microsoft.VisualBasic.Collection which may work with WB and the CLR.  Basic rock and hard place - While I prefer a strict WB solution because it is generally easier and a real coding time saver - I need to hedge my bets by linking in COM or NET objects or pushing Powershell code.
Title: Re: WIN10 Collection Issues
Post by: bmclellan on October 23, 2019, 07:30:19 PM
Hi Tony,

What are WIL Maps?
Title: Re: WIN10 Collection Issues
Post by: td on October 24, 2019, 08:47:10 AM
WIL Maps are the WIL implementation of associative arrays.  Navigate to Home -> Windows Interface Language Reference -> Functions -> Alphabetical -> MapCreate in the Consolidated WIL Help file for a concise explanation of WIL map usage.  Go to  Home -> Windows Interface Language Reference -> Functions -> By Type -> Maps (Associative Arrays) -> Map Functions in the Consolidated WIL Help file to get a brief definition of WIL maps.

If you do not have that information in your copy of the Consolidated WIL Help file, you are using an old version of WinBatch and it does matter.  You can't use them unless you get a newer copy of WinBatch+Compiler.
Title: Re: WIN10 Collection Issues
Post by: kdmoyers on October 24, 2019, 11:53:41 AM
((good gracious I love the new maps -- quick, clean, gets it done))
Title: Re: WIN10 Collection Issues
Post by: chrislegarth on October 25, 2019, 01:01:18 PM
Maps are the next best thing to sliced bread!!!