Sign in to follow this  
Followers 0
E1M1

Need array help

6 posts in this topic

#1 ·  Posted (edited)

Hello, can anyone help me with array plz?

my program starts with

$Items[0] = ""
and I get result

C:\My Documents\11-2008\myscript3.au3(1,20) : WARNING: $Items possibly not declared/created yet
$Items[0] = ""
~~~~~~~~~~~~~~~~~~~^
C:\My Documents\11-2008\myscript3.au3 - 0 error(s), 1 warning(s)
->22:22:26 AU3Check ended.rc:1
>Running:(3.2.12.1):C:\Program Files\AutoIt3\autoit3.exe "C:\My Documents\11-2008\myscript3.au3"    
C:\My Documents\11-2008\myscript3.au3 (1) : ==> Expected a "=" operator in assignment statement.:
$Items[0] = ""
$Items^ ERROR

I want to create function that generates array and as I understood I must define $items before I can create array.Also my function will always generate different number of array items.

It would be great if someone would give me an example about creating array[n]

Thanks!

Edited by E1M1

edited

Share this post


Link to post
Share on other sites



Hello, can anyone help me with array plz?

my program starts with

$Items[0] = ""
and I get result

C:\My Documents\11-2008\myscript3.au3(1,20) : WARNING: $Items possibly not declared/created yet
$Items[0] = ""
~~~~~~~~~~~~~~~~~~~^
C:\My Documents\11-2008\myscript3.au3 - 0 error(s), 1 warning(s)
->22:22:26 AU3Check ended.rc:1
>Running:(3.2.12.1):C:\Program Files\AutoIt3\autoit3.exe "C:\My Documents\11-2008\myscript3.au3"    
C:\My Documents\11-2008\myscript3.au3 (1) : ==> Expected a "=" operator in assignment statement.:
$Items[0] = ""
$Items^ ERROR

I want to create function that generates array and as I understood I must define $items before I can create array.Also my function will always generate different number of array items.

It would be great if someone would give me an example about creating array[n]

Thanks!

right from the help file under DIM

To initialize an array, specify the values for each element inside square brackets, separated by commas. For multiple dimensions, nest the initializers. You can specify fewer elements in the initializer than declared, but not more. Function calls can also be placed in the initializers of an array. If the function call returns an array, then the one array element will contain that returned array.

Dim $Array1[12]=[3, 7.5, "string"], $array[5] = [8, 4, 5, 9, 1]

Dim $Grid[2][4]=[["Paul", "Jim", "Richard", "Louis"], [485.44, 160.68, 275.16, 320.00]]

Dim $Test[5] = [3, 1, StringSplit("Abe|Jack|Bobby|Marty", "|"), Cos(0)]


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

thanks, now I tried

Dim $RemoveItems[1]
$RemoveItems[0] = 0
....
....
$Items[0] += 1
$Items[1] = $text

and I got

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$Items[1] = $text

edited

Share this post


Link to post
Share on other sites

thanks, now I tried

Dim $RemoveItems[1]
$RemoveItems[0] = 0
....
....
$Items[0] += 1
$Items[1] = $text

and I got

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$Items[1] = $text
Adding 1 to theh [0] element does not create a new [1] element that wasn't there before. If you want to resize the array without destroying its contents, use ReDim:
Dim $RemoveItems[1]
$RemoveItems[0] = 0
....
....
$Items[0] += 1
ReDim $Items[$Items[0] + 1]
$Items[1] = $text

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks, but now I have new proplem sorry for posting so much :)

Now I have

Dim $Items[1]

$Items[0] = 0

....

....

Case $Button1

Func1($Items)

Case $Button2

For $i = 1 To $Items[0]

If $Items[0] = 0 Then

ExitLoop

EndIf

$Name = $Items[$i]

Func2($sName)

....

....

Func Func1(byref $Items)

;every time new text gained, array resized and new text added as Items[n]

$Items[0] += 1

$Items[1] = $text

EndFunc

....

func Func2()

EndFunc()

When I click on $Button2 I get error says:

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$sName = $Items[$i]

Edited by E1M1

edited

Share this post


Link to post
Share on other sites

Thanks, but now I have new proplem sorry for posting so much :)

Now I have

When I click on $Button2 I get error says:

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$sName = $Items[$i]

So where did you ReDim the array...?

:lmao:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  
Followers 0