Jump to content
Sign in to follow this  
rdr

Array() equivalent

Recommended Posts

rdr
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

Share this post


Link to post
Share on other sites
FireFox

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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
FireFox

@water,

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

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
water

Opps, sorry :>

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Mat

This does work though:

Local $a = []

Edit: Though UBound($a) returns 1 for that. What firefox suggested (Local $a[0]) works.

Edited by Mat

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
rdr

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

Share this post


Link to post
Share on other sites
trancexx

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

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
trancexx

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

Share this post


Link to post
Share on other sites
FireFox

[] = [Null] maybe.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
trancexx

[] = [""]

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

Share this post


Link to post
Share on other sites
trancexx

It's clear what this is:

Local $aArray = [[]]

Right?

Or this maybe:

Local $aArray = [[[[]]]]

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
trancexx

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

Share this post


Link to post
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
Sign in to follow this  

×