Jump to content

Array() equivalent


rdr
 Share

Go to solution Solved by Mat,

Recommended Posts

Hello,
 
I need to make a call to a method that takes as a parameter a variant that should be an array of properties. For the specific function that I need to be executed, there are no needed properties, so I would need to pass an empty array. In VB I would just use the Array() constructor, but in AutoIt what can I use? Is there something equivalent?
 
Thank you
Link to comment
Share on other sites

Welcome to AutoIt and the forum!

You need the latest Beta version of AutoIt. There you can create an empty array.

Global $aArray[]
ConsoleWrite(UBound($aArray) & @LF)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Opps, sorry :>

Looks like I need to get my feet wet with the new features.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

It's an array, but not an empty array.

Global $aArray = []
ConsoleWrite(VarGetType($aArray) & @LF)
ConsoleWrite(UBound($aArray, 1) & @LF)

returns 1. Strange.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thank you very much for your replies. I installed the Beta version and compiled the script again but unfortunately I am getting COM errors ('interface not registered' for $array[] and 'type mismatch' for $array = []). So, I am guessing there must be some small difference in the implementation of the empty table in autoit?

EDIT: It turns out I was passing another parameter wrong and $array = [] did the job after all! Thank you very much again!

Edited by rdr
Link to comment
Share on other sites

It's an array, but not an empty array.

Global $aArray = []
ConsoleWrite(VarGetType($aArray) & @LF)
ConsoleWrite(UBound($aArray, 1) & @LF)
returns 1. Strange.

 

 

It's not strange, it's opposite of that. Consistent with the syntax rules of AutoIt:

#include <Array.au3>

Local $aArray[5] = [1, 2]

_ArrayDisplay($aArray)

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Seems I'm a bit slow on the uptake (today).

Why does UBound($aArray4) return 1? Shouldn't it be 0?

Global $aArray1[0], $aArray2[1], $aArray3 = [1], $aArray4 = []
ConsoleWrite("UBound($aArray1, 1): " & UBound($aArray1, 1) & @LF)
ConsoleWrite("UBound($aArray2, 1): " & UBound($aArray2, 1) & @LF)
ConsoleWrite("UBound($aArray3, 1): " & UBound($aArray3, 1) & @LF)
ConsoleWrite("UBound($aArray4, 1): " & UBound($aArray4, 1) & @LF)

>Running:(3.3.9.19):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "C:TempTest.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop

UBound($aArray1): 0
UBound($aArray2): 1
UBound($aArray3): 1
UBound($aArray4): 1

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Because array4 has one element - an empty string, because AutoIt doesn't know for "nothing", it always has to be something.

Array literal implies "something".

You may not see the obvious on that simple example, but for more complex ones (multidimensional arrays literals) it will be clear, only your head might hurt at first. jchd can explain better, he's good with words.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Now it's clear, thanks.

I still prefer to define 2 or 4-dimensional arrays the "traditional" way ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...