Jump to content

Error trying to Dim Array


Recommended Posts

I'm trying use a simple static array in my script. In trying to track down the exact cause of the error, I reduced my script to one line: the dim statement. Even this gets the error: "No variable given for "Dim","Local","Global" or "Const" statement.

This occurs even when I cut and paste the exact example given in the online documentation:

Dim $Array1[12]=[3, 7.5, "string"]

(For the record, I've also tried to simplify this by using Dim $array[3]=[1,2,3] and several other super simple arrays. But I still get this error every time.) Just to add another curveball, I tried using Dim Const $Array1[3]=[1,2,3]. This gives a different error message: Expected a "=" operator in the assignment statement, with the caret pointing to the subscript bracket. This would make sense if AutoIT3.exe thought I were Dimming a scalar... but I want an array!

It seems to me that maybe the documentation is wrong here, otherwise cutting and pasting ought not to produce this error. What's the correct syntax here? Or am I missing something obvious?

Edited by Michael McNally
Link to comment
Share on other sites

Hi,

try this:

#include<array.au3>

If @AutoitVersion <= "3.2.1.0" Then MsgBox(64, "Error", "Old Version")
    
Dim $Array1[12]=['',3, 7.5, "string"]
Dim $Array1[4]=['',3, 7.5, "string"]
Dim $Array1[3]=[5, 7.5, "string"]

_ArrayDisplay($Array1, "")

So long,

Mega

PS: You do not need the version check that high in version, but you need the new 3.2 version or 3.1.1. beta

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Thanks. I have AutoIt installed on 3 different computers. All of them have the latest version except of course the machine I am on today. I had version 3.1.1.0, at least thats the version number which showed in the file properties, not sure whether it was beta or not. I downloaded and unzipped the latest and all seems ok now.

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