Jump to content

Array() equivalent


Go to solution Solved by Mat,

Recommended Posts

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

Hi,

Welcome to the autoit forum :)

In the beta version you can create empty arrays (e.g: $aArray[0]), I don't know if it's what you're looking for.

Br, FireFox.

Posted

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 2024-07-28 - Version 1.6.3.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 (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

 

Posted

Opps, sorry :>

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

 

Posted

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 2024-07-28 - Version 1.6.3.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 (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

 

Posted (edited)

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
Posted

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 2024-07-28 - Version 1.6.3.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 (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

 

Posted

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

Posted

[] = [""]

In current language implementation yes. Tomorrow it may be something else. If you leave AutoIt to fill unspecified elements then AutoIt will always use what's "nothing" to it.

So there is no such thing as an empty array literal then?

No. And yes. But no.

♡♡♡

.

eMyvnE

Posted

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 2024-07-28 - Version 1.6.3.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 (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

 

Posted

I do too.

I also think that the language shuldn't, just because of that, have (unlogical) boundaries that would restrict users from prefering something else.

Lifted boundaries give new possibilites even for us.

♡♡♡

.

eMyvnE

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
  • Recently Browsing   0 members

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