Zopieux Posted October 13, 2007 Share Posted October 13, 2007 Hi all,I have two little interrogations.First, how to declare a 2 dimensional array without size limit.E.g. : Dim $array[][2] (but of course it is not working)Then, I tested the _ArrayAdd function with a 2 dimensional array but it is not working : the func doesn't support it ?I want to insert "Bar" in the second dimension of $foo[] with the fonction _ArrayAdd for instance. How can I do it ?Thank in advance ! Best regards,Zopieux I'm not English, then please excuse my spelling :) Link to comment Share on other sites More sharing options...
Developers Jos Posted October 13, 2007 Developers Share Posted October 13, 2007 Hi all, I have two little interrogations. First, how to declare a 2 dimensional array without size limit. E.g. : Dim $array[][2] (but of course it is not working) Then, I tested the _ArrayAdd function with a 2 dimensional array but it is not working : the func doesn't support it ? I want to insert "Bar" in the second dimension of $foo[] with the fonction _ArrayAdd for instance. How can I do it ? Thank in advance ! Best regards, ZopieuxYou need to set the size... You can always increase it with a redim .... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Zopieux Posted October 13, 2007 Author Share Posted October 13, 2007 Ok, thanks. But what about the second problem ? I'm not English, then please excuse my spelling :) Link to comment Share on other sites More sharing options...
Developers Jos Posted October 13, 2007 Developers Share Posted October 13, 2007 Ok, thanks. But what about the second problem ? just write your own function .... _ArrayAdd() only works on single dimed arrays... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
weaponx Posted October 13, 2007 Share Posted October 13, 2007 (edited) Dim $array[4][2] = [["John", "Smith"],["Steven", "Tyler"],["Jean", "Grey"],["Abe","Lincoln"]] _ArrayDisplay($array) _ArrayAddX($array, "Dan", "Marino") _ArrayDisplay($array) Func _ArrayAddX(ByRef $myA, $value1, $value2) Redim $myA[Ubound($array) + 1][Ubound($myA, 2)] $myA[Ubound($array) - 1][0] = $value1 $myA[Ubound($array) - 1][1] = $value2 EndFunc EDIT: This is for 2 dimensions only. Beyond 2 dimensions you have to pass an array to the function and it just looks messy. Edited October 13, 2007 by weaponx Link to comment Share on other sites More sharing options...
Zopieux Posted October 13, 2007 Author Share Posted October 13, 2007 Many thanks, I am going to test it right now. I'm not English, then please excuse my spelling :) Link to comment Share on other sites More sharing options...
Zopieux Posted October 15, 2007 Author Share Posted October 15, 2007 Ok, there is a problem : the debug says : C:\...\file.au3 (142) : ==> Variable used without being declared.: Redim $myA[ubound($array) + 1][ubound($myA, 2)]The function is placed at the end of the code. What have I to do ? I'm not English, then please excuse my spelling :) Link to comment Share on other sites More sharing options...
randallc Posted October 15, 2007 Share Posted October 15, 2007 Ok, there is a problem : the debug says : The function is placed at the end of the code. What have I to do ?Hi, Easiest to get help if you post your script; either add it to your post ["Browse","Upload"], or put it in "AutoIt" message box in edit (under combobox with "Insert Special Item") 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...
weaponx Posted October 15, 2007 Share Posted October 15, 2007 Well it tested okay for me but I forgot I changed up some of the variable names. #include <array.au3> Dim $array[4][2] = [["John", "Smith"],["Steven", "Tyler"],["Jean", "Grey"],["Abe","Lincoln"]] _ArrayDisplay($array) _ArrayAddX($array, "Dan", "Marino") _ArrayDisplay($array) Func _ArrayAddX(ByRef $myA, $value1, $value2) Redim $myA[Ubound($myA) + 1][Ubound($myA, 2)] $myA[Ubound($myA) - 1][0] = $value1 $myA[Ubound($myA) - 1][1] = $value2 EndFunc Link to comment Share on other sites More sharing options...
Zopieux Posted October 15, 2007 Author Share Posted October 15, 2007 (edited) EDIT: ok, weaponx, it is now working, but your function adds the entry at the end of the array, even if there is nothing before... Is it possible to change something/create a new function which fixes the problem ? Edited October 15, 2007 by Zopieux I'm not English, then please excuse my spelling :) Link to comment Share on other sites More sharing options...
weaponx Posted October 15, 2007 Share Posted October 15, 2007 (edited) What are the original dimensions for your array? Show me the code that declares $Rep EDIT: I reposted the function. Did you try the new code? Edited October 15, 2007 by weaponx Link to comment Share on other sites More sharing options...
Zopieux Posted October 15, 2007 Author Share Posted October 15, 2007 Ok, I have just edited my message. Can you take a look at it ? I'm not English, then please excuse my spelling :) Link to comment Share on other sites More sharing options...
weaponx Posted October 15, 2007 Share Posted October 15, 2007 (edited) The whole purpose of this is that it lets you declare a 1x2 array and it will redimension it for you. I believe _ArrayAdd would do the same thing for a one-dimensional array. Edited October 15, 2007 by weaponx Link to comment Share on other sites More sharing options...
Zopieux Posted October 15, 2007 Author Share Posted October 15, 2007 Fine, I will declare the littlest array I can. But there is another problem (I hate arrays ) : I will need a function to remove an entry of this 2 dimensional array. Is it possible ? I wonder if _ArrayDelete can work on a 2 dimensional array... I'm not English, then please excuse my spelling :) Link to comment Share on other sites More sharing options...
weaponx Posted October 15, 2007 Share Posted October 15, 2007 Dim $array will resize AND delete its contents. Redim $array will only resize. So you if you had an array like: Dim $array[40][2] Redim $array[45][2] would make it larger Dim $array[40][2] would flush it Link to comment Share on other sites More sharing options...
Zopieux Posted October 15, 2007 Author Share Posted October 15, 2007 Ok, many thanks, problems are resolved ! Best regards. I'm not English, then please excuse my spelling :) Link to comment Share on other sites More sharing options...
randallc Posted October 15, 2007 Share Posted October 15, 2007 Fine, I will declare the littlest array I can.But there is another problem (I hate arrays ) : I will need a function to remove an entry of this 2 dimensional array. Is it possible ? I wonder if _ArrayDelete can work on a 2 dimensional array...Hi,You can use 'Array2D.au3" from my sig, which has Arraydel2D, ArrayInsert2D ets pre-written; or write your own.I was using large arrays, so converted the UDF to use Scriptcontrol vbs for speed, but originally they were in AutoIt; can find it somewhere if you want.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...
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