J_Y_C Posted August 14, 2006 Share Posted August 14, 2006 (edited) I am trying to use a 2 dimensional array, but I keep getting the error message:C:\xxxxxxx\Automation Scripts\PixelPopper.au3 (25) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: The line that it refers to is here:Global $lineCoors[5][4];Line coordinate data array $lineCoors[5][1] = ("Line_Top_y_value") $lineCoors[5][2] = ("Line_Bottom_y_value") $lineCoors[5][3] = ("Line_Left_x_value") $lineCoors[5][4] = ("Line_Right_x_value")Line 25 is $lineCoors[5][1] = ("Line_Top_y_value"), the first one. Am I declaring the array properly? Can arrays not have string values? Edited August 14, 2006 by J_Y_C Link to comment Share on other sites More sharing options...
ddeerr Posted August 14, 2006 Share Posted August 14, 2006 I am trying to use a 2 dimensional array, but I keep getting the error message: C:\Documents and Settings\jchen.KARAOKEWH\Desktop\Automation Scripts\PixelPopper.au3 (25) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: The line that it refers to is here: Global $lineCoors[5][4];Line coordinate data array $lineCoors[5][1] = ("Line_Top_y_value") $lineCoors[5][2] = ("Line_Bottom_y_value") $lineCoors[5][3] = ("Line_Left_x_value") $lineCoors[5][4] = ("Line_Right_x_value")oÝ÷ ظ§{nb³Mú)Þ +³ This code was working for me since i get the new autoit version Link to comment Share on other sites More sharing options...
bluebearr Posted August 14, 2006 Share Posted August 14, 2006 Arrays in AutoIt are zero based. When you declare them, you are specifying the number of elements, not the index of the last element. So, your highest-numbered index will always be one less than the number you used in your declaration.In other words, if you declare Global $myarray[5]It will have these elements: $myarray[0] $myarray[1] $myarray[2] $myarray[3] $myarray[4]Thus, $myarray[5] will cause AutoIt to complain about dimension ranges exceeded. BlueBearrOddly enough, this is what I do for fun. Link to comment Share on other sites More sharing options...
J_Y_C Posted August 14, 2006 Author Share Posted August 14, 2006 Ok, this may be a totally stupid question, but if I install the new version, do I need to uninstall the older ones? I am currently using the beta, does the new release have all of the functions that are in the Beta? Link to comment Share on other sites More sharing options...
J_Y_C Posted August 14, 2006 Author Share Posted August 14, 2006 (edited) Ah ha! thank you Bluebearr!! UPDATE So, I changed it to this: Global $lineCoors[6][5];Line coordinate data array $lineCoors[5][1] = ("Line_Top_y_value") $lineCoors[5][2] = ("Line_Bottom_y_value") $lineCoors[5][3] = ("Line_Left_x_value") $lineCoors[5][4] = ("Line_Right_x_value") got it, thanks... Edited August 14, 2006 by J_Y_C Link to comment Share on other sites More sharing options...
bluebearr Posted August 14, 2006 Share Posted August 14, 2006 I uninstalled all previous versions, including Scite (the editor, if you've installed it) and cleared the program directory, then installed fresh. Been working for me. BlueBearrOddly enough, this is what I do for fun. Link to comment Share on other sites More sharing options...
ddeerr Posted August 14, 2006 Share Posted August 14, 2006 Hi, I have the same message with this loop : Local $i=1 ; i forgot :) While $lettresMapDispo [$i] <> "0" GUICtrlSetData($ctrlComboId, $lettresMapDispo [$i]) $i = $i + 1 WEnd This code was working for me since i get the new autoit version my problem is not solved and it doesn't concern the array use. Link to comment Share on other sites More sharing options...
J_Y_C Posted August 14, 2006 Author Share Posted August 14, 2006 Unless I am mistaken, I believe that all arrays have to be explicitly declared in AutoIt... Link to comment Share on other sites More sharing options...
Danny35d Posted August 14, 2006 Share Posted August 14, 2006 (edited) $i = $i + 1oÝ÷ Øhmz0¬oMúëmëjâ²?m»j|g«tߨ¤yêZuا©ÝÆ⫶§Ê«jºÚɽ7êW¶·¬1ªCÊhý¼¨»¥¯zØ^±©ë,j¯+(ëax%GºÚ"µÍØØ[ ÌÍÚOLHÈHÜÛÝÚ[HPÝ[ ÌÍÛ]ÓXÜÊH ÉÝÈ ÌÍÚBÕRPÝÙ]]J ÌÍØÝÛÛXÒY ÌÍÛ]ÓXÜÈÉÌÍÚWJB ÌÍÚHH ÌÍÚH ÈBÑ[ Edit: typo Edited August 14, 2006 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
J_Y_C Posted August 24, 2006 Author Share Posted August 24, 2006 Arrays in AutoIt are zero based. When you declare them, you are specifying the number of elements, not the index of the last element. So, your highest-numbered index will always be one less than the number you used in your declaration. In other words, if you declare Global $myarray[5] It will have these elements: $myarray[0] $myarray[1] $myarray[2] $myarray[3] $myarray[4] Thus, $myarray[5] will cause AutoIt to complain about dimension ranges exceeded. We resolved this thread a while back, and I was thinking back and realized that something bluebearr said didn't make sense to me, and needs to be resolved. In this quote, you say that AutoIt is zero based when it comes to arrays (like most languages). However, in the helpfile, it kind of seems to contradict this: Arrays An Array is a variable containing series of data elements of the same type and size. Each element in this variable can be accessed by an index number. An example: Let's say you want to store these series of characters: "A", "U", "T", "O", "I", "T" and "3". You could use seven separate variables to do so, but using an Array is more efficient: $Array[1]="A" $Array[2]="U" ..etc.. $Array[7]="3" To access a specific value in an Array, you only have to know the index number: $MyChar=$Array[3] This results in $MyChar containing the letter "T" (See also: 'operators'). Here, I am led to believe that the first item in an array is actually 1 ! Was this example done this way just for simplicity? Link to comment Share on other sites More sharing options...
ame1011 Posted August 24, 2006 Share Posted August 24, 2006 We resolved this thread a while back, and I was thinking back and realized that something bluebearr said didn't make sense to me, and needs to be resolved. In this quote, you say that AutoIt is zero based when it comes to arrays (like most languages). However, in the helpfile, it kind of seems to contradict this: Here, I am led to believe that the first item in an array is actually 1 ! Was this example done this way just for simplicity? It was... Some people choose to skip the zero and start from one. However, when doing this, remember that you must declare the array to be 1 more than the biggest element you are going to use. ie: if the largest element that you are going to use is 5: $array[5] then you would need to declare the array like so: Dim $array[6] because although you are not using the 0, its still there and being counted [font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font] Link to comment Share on other sites More sharing options...
randallc Posted August 25, 2006 Share Posted August 25, 2006 (edited) hi, And the really confusing language is vbscript, where "ubound" gives the last index number (say the last element number is 5 then vbscript ubound (array) is 5, even though the vbscript array also is numbered 0 to5 , so has 6 elements! ); whereas Autoit gives ubound as the number of elements instead of the last index number! best, Randall Edited August 25, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
MHz Posted August 25, 2006 Share Posted August 25, 2006 @randallc, Would depend on your definition of UBound(). If the upper boundary is outside the limits (i.e subscript error caused), then VBS users would consider that as wierd. Looking at VBS for strengths and weaknesses in the language, I consider arrays are one of the strengths of VBS. Especially the dynamic arrays. But VBS runtime is much larger compared to AutoIt's, so they are more diversified. It may look strange to you perhaps because you have not had enough time to understand them? Dim MyArray() With the above VBS dynamic array declared, you can later ReDim the above to resize and use UBound to give you the upper boundary (not out of bounds). No computation needed. Link to comment Share on other sites More sharing options...
randallc Posted August 25, 2006 Share Posted August 25, 2006 Hi, 2MHz, Yes, tongue in cheek about vbs. I agree; But making a point that there IS a difference VBscript=================== dim array(5) array item 0,1,2,3,4,5 ('5' would be NOT oob) uboundarray()=5 (but 6 items!) AutoIt=================== dim array[5] array item 0,1,2,3,4 ('5' would be oob) uboundarray()=6 (for same 6 items!) Best, randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
GaryFrost Posted August 25, 2006 Share Posted August 25, 2006 (edited) Hi, 2MHz, Yes, tongue in cheek about vbs. I agree; But making a point that there IS a difference VBscript=================== dim array(5) array item 0,1,2,3,4,5 ('5' would be NOT oob) uboundarray()=5 (but 6 items!) AutoIt=================== dim array[5] array item 0,1,2,3,4 ('5' would be oob) uboundarray()=6 (for same 6 items!) Best, randall Comparing vbs arrays to autoit (C/C++) arrays is a mute point Anyone that knows how c works with arrays will know that what you call zero base index is an offset Dim $array[5] $array[0] is 0 offset from 1st position in the array $array[1] is 1 offset from 1st position in the array etc... Therefore $array[4] is 4 offset from 1st postion hence 5th item in array. Even tho both access the array the same the declaration has different meaning vbs - array[5] = 5 is the last index therefore declaring 6 items in the array c - array[5] = delcaring 5 items in the array Edited August 25, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. 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