viewpoint-particle

Author Topic: WIN10 Collection Issues  (Read 377 times)

stanl

  • Pundit
  • *****
  • Posts: 948
WIN10 Collection Issues
« 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: Text
]
d = CreateObject("VBA.Collection")
d.Add( "Athens" )
d.Add( "Belgrade" )
d.Add( "Cairo" )
 

[/font]But I can initialize

Code: Winbatch

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
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]

 

stanl

  • Pundit
  • *****
  • Posts: 948
Re: WIN10 Collection Issues
« Reply #1 on: December 09, 2018, 08:48:25 am »
I hate stumbling on something that works after posting... this worked.


Code: Winbatch

ForEach k in d.Keys
   message(k,d.item(k))
Next
 

td

  • Tech Support
  • *****
  • Posts: 3079
    • WinBatch
Re: WIN10 Collection Issues
« Reply #2 on: December 09, 2018, 08:50:26 am »
Or

Code: Winbatch
a = d.keys()
for i = 0 to d.count - 1
   k = a[i]
next
 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

  • Tech Support
  • *****
  • Posts: 3079
    • WinBatch
Re: WIN10 Collection Issues
« Reply #3 on: December 09, 2018, 08:54:18 am »
Or just use WIL maps.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

  • Pundit
  • *****
  • Posts: 948
Re: WIN10 Collection Issues
« Reply #4 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.

bmclellan

  • Newbie
  • *
  • Posts: 29
Re: WIN10 Collection Issues
« Reply #5 on: October 23, 2019, 07:30:19 pm »
Hi Tony,

What are WIL Maps?

td

  • Tech Support
  • *****
  • Posts: 3079
    • WinBatch
Re: WIN10 Collection Issues
« Reply #6 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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

kdmoyers

  • Sr. Member
  • ****
  • Posts: 290
Re: WIN10 Collection Issues
« Reply #7 on: October 24, 2019, 11:53:41 am »
((good gracious I love the new maps -- quick, clean, gets it done))
The mind is everything; What you think, you become.

chrislegarth

  • Newbie
  • *
  • Posts: 41
Re: WIN10 Collection Issues
« Reply #8 on: October 25, 2019, 01:01:18 pm »
Maps are the next best thing to sliced bread!!!