Guest autoit3 Posted September 29, 2004 Share Posted September 29, 2004 (edited) $a[0] = 0 $a^ ERROR Error: Expected a "=" operator in assignment statement. --- How do I assign a value to an element of the array $a? My above attempt resulted in error. Edit: Title should read "$a[0] = 0" instead of "$a[0] = $zero", question still stands. Edited September 29, 2004 by autoit3 Link to comment Share on other sites More sharing options...
OminousIdol Posted September 29, 2004 Share Posted September 29, 2004 ;//Just A Example! Dim $array[5], $zero $array[0] = $zero $array[1] = $one $array[2] = $two $array[3] = "Three";If you are setting a varible or a arry to hold text use quotes! Thats all you need to do to set arrays to whatever you want! OminousIdol Link to comment Share on other sites More sharing options...
Guest autoit3 Posted September 29, 2004 Share Posted September 29, 2004 (edited) ;//Just A Example! Dim $array[5], $zero $array[0] = $zero $array[1] = $one $array[2] = $two $array[3] = "Three";If you are setting a varible or a arry to hold text use quotes!Thats all you need to do to set arrays to whatever you want!OminousIdol<{POST_SNAPBACK}>Thank You!!--Some $a[0] = 0 statements still geneate the error "Expected a "=" operator in assignment statement" -- any ideas? Edited September 29, 2004 by autoit3 Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted September 29, 2004 Share Posted September 29, 2004 I think it's because you need more than just the $a[0], I think you also need at least $a[1] or another one. Link to comment Share on other sites More sharing options...
Guest autoit3 Posted September 29, 2004 Share Posted September 29, 2004 (edited) I think it's because you need more than just the $a[0], I think you also need at least $a[1] or another one.<{POST_SNAPBACK}>Global $a[2] $a[0] = 0;fine $a[0] = 0;error, "needs = operator"Pretty sure it is a bug?Update: Apparently the more elements I declare in the $a array the more times it allows me to initilize the zeroith element. It seems to also randomly complain that $a[0] = 0 is missing a "=". Either this is a bug in the code or arrays are handeled irregularly in AutoIt.. ? I need to be able to constantly reset $a[0] within a loop structure, for some reason I appear to be limited by the amount of elements I declare in the array. Help please! Edited September 29, 2004 by autoit3 Link to comment Share on other sites More sharing options...
MHz Posted September 29, 2004 Share Posted September 29, 2004 What about this example? Global $array[4], $zero = 2, $one = 5, $two = 10 $array[0] = $zero $array[1] = $one $array[2] = $two $array[3] = "Three";If you are setting a varible or a arry to hold text use quotes! MsgBox(0,'title' , 'This equals ' & $array[3]) Does this help? Link to comment Share on other sites More sharing options...
ZeDMIN Posted September 29, 2004 Share Posted September 29, 2004 Global $a[2] $a[0] = 0;fine $a[0] = 0;error, "needs = operator"Pretty sure it is a bug?Update: Apparently the more elements I declare in the $a array the more times it allows me to initilize the zeroith element. It seems to also randomly complain that $a[0] = 0 is missing a "=". Either this is a bug in the code or arrays are handeled irregularly in AutoIt.. ? I need to be able to constantly reset $a[0] within a loop structure, for some reason I appear to be limited by the amount of elements I declare in the array. Help please!<{POST_SNAPBACK}>Global $a[2] $a[0] = 0 $a[0] = 0 $a[0] = 0 $a[0] = 0 $a[0] = 0 $a[0] = 0 For $I = 1 To 100 $a[0] = 0 Next MsgBox(0, '', $a[0])that works fine here. maybe theres some other error in your script? a complete copy+paste would be helpful i think. (if it's not too big)Greetings,ZeD Link to comment Share on other sites More sharing options...
Guest autoit3 Posted October 1, 2004 Share Posted October 1, 2004 I deleted the script so it doesent matter anymore. Thanks for the help though. Link to comment Share on other sites More sharing options...
normeus Posted October 3, 2004 Share Posted October 3, 2004 I deleted the script so it doesent matter anymore. Thanks for the help though.<{POST_SNAPBACK}>yet another sample:Dim $a[5]$a[0] = 0 $a[4] = " 5th element" MsgBox(1, "", $a[0] & $a[4])so, an array has to be DIM (dimensioned) for autoit3 to know how big it will be(because it has to reserve a chunk of memory for the array)my array $a[5] has 5 elements from $a[0] to a$[4]DON'T try to use $a[5] it does not exist because the index starts at zeroI use MsgBox as my trusty print command for debugging purposes http://www.autoitscript.com/autoit3/scite/...iTe4AutoIt3.exe Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted October 3, 2004 Share Posted October 3, 2004 yet another sample:Dim $a[5]$a[0] = 0 $a[4] = " 5th element" MsgBox(1, "", $a[0] & $a[4])so, an array has to be DIM (dimensioned) for autoit3 to know how big it will be(because it has to reserve a chunk of memory for the array)my array $a[5] has 5 elements from $a[0] to a$[4]DON'T try to use $a[5] it does not exist because the index starts at zeroI use MsgBox as my trusty print command for debugging purposes<{POST_SNAPBACK}>I didn't think AutoIt reserved the memory space until you place a value in the memory slot?*** Matt @ MPCS 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