E1M1 Posted February 3, 2009 Share Posted February 3, 2009 (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 February 3, 2009 by E1M1 edited Link to comment Share on other sites More sharing options...
nitekram Posted February 3, 2009 Share Posted February 3, 2009 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)] 2¢ 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." 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 Link to comment Share on other sites More sharing options...
E1M1 Posted February 3, 2009 Author Share Posted February 3, 2009 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 Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 3, 2009 Share Posted February 3, 2009 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 Link to comment Share on other sites More sharing options...
E1M1 Posted February 3, 2009 Author Share Posted February 3, 2009 (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 February 3, 2009 by E1M1 edited Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 3, 2009 Share Posted February 3, 2009 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...? 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now