martin Posted September 10, 2007 Posted September 10, 2007 Should it be possible to create a struct like this? DllStructCreate("char[40][2]") which I would expect to be the same as DllStructCreate("char[40];char[40]") Here is a script which shows it doesn't work, but maybe I'm doing something wrong. $d1 = DllStructCreate("char[40];char[40]") DllStructSetData($d1,1,"first string") DllStructSetData($d1,2,"second string") $d2 = DllStructCreate("char[40][2]") DllStructSetData($d2,1,"apples are fruit",1) DllStructSetData($d2,1,"oranges are fruit",2) ;this works $s1 = DllStructGetData($d1,1) $s2 = DllStructGetData($d1,2) MsgBox(0,$s1,$s2) ;this doesn't $s1 = DllStructGetData($d2,1,1) $s2 = DllStructGetData($d2,1,2) MsgBox(0,$s1,$s2) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Moderators SmOke_N Posted September 10, 2007 Moderators Posted September 10, 2007 (edited) I would think that char[40][2] would be like 40 elements at 2 bytes each. Edit: I also don't see an option for multi dimensions ? Edited September 10, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Siao Posted September 10, 2007 Posted September 10, 2007 (edited) I think the problem in such array char[40][2] is that each of 80 elements still has a length of 1 byte (char). Edited September 10, 2007 by Siao "be smart, drink your wine"
seandisanti Posted September 10, 2007 Posted September 10, 2007 Siao said: I think the problem in such array char[40][2] is that each element still has a length of 1 byte (char).yeah it looks like it's most likely a combination of the wrong data type being used, as you and smoke said, and i'm not sure that you can call dllstructcreate() with a multidimensional array as an argument...
The Kandie Man Posted September 11, 2007 Posted September 11, 2007 You can't create multidimensional char arrays. A char is an array of numbers where each element of the array contains the integer decimal ASCII code for each character in the string. That is what a string is in lower level languages, an array of ASCII codes. Therefore, you can't create a multidimensional array like that. - The Kandie Man ;-) "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire
martin Posted September 11, 2007 Author Posted September 11, 2007 SmOke_N said: I would think that char[40][2] would be like 40 elements at 2 bytes each. I wondered that myself and so I tried "char[2][40]" but it didn't help. Quote I also don't see an option for multi dimensions ? I think that is the problem, multidimensional arrays just aren't designed into dllstruct. I just hoped that since you can have an array of ints or ptrs, then maybe an array of strings. I suppose that what you would normally do is to have an array of strings and then have a pointer to the array, but how do you do that in AutoIt? It's a pity because if I want 100 strings each up to 39 characters I have to create a string with "char[40];char[40]... " 100 times instead of "char[40][100], but it's no big deal. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
martin Posted September 11, 2007 Author Posted September 11, 2007 The Kandie Man said: You can't create multidimensional char arrays. A char is an array of numbers where each element of the array contains the integer decimal ASCII code for each character in the string. That is what a string is in lower level languages, an array of ASCII codes. Therefore, you can't create a multidimensional array like that. - The Kandie Man ;-) When you say a char is an array of numbers you mean a string is an array of numbers. (Or maybe you mean a char array) Just because of that it doesn't mean you can't have a multidimensional char arrays. In C for example, which treats strings as character arrays, you can have declarations like char testarray[40][100] and that will work fine. You can use testarray[0] or testarray[12] as separate strings. If you couldn't create a multidimensional array because each element is a number then you couldn't have multidimensional arrays for anything! If the dllstruct was designed to cope with arrays of strings then there would be no reason not to have char[40][100] and then reference each set of 40 characters as you do for integer arrays with the element and the index. The reason it doesn't work, I assume, is because it's not designed in to work, and not because you can't have multidimensional character arrays. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Moderators SmOke_N Posted September 11, 2007 Moderators Posted September 11, 2007 martin said: I wondered that myself and so I tried "char[2][40]" but it didn't help. I think that is the problem, multidimensional arrays just aren't designed into dllstruct. I just hoped that since you can have an array of ints or ptrs, then maybe an array of strings. I suppose that what you would normally do is to have an array of strings and then have a pointer to the array, but how do you do that in AutoIt? It's a pity because if I want 100 strings each up to 39 characters I have to create a string with "char[40];char[40]... " 100 times instead of "char[40][100], but it's no big deal.After reading this, and posting, I played with that very idea... I got no where with it though. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
martin Posted September 12, 2007 Author Posted September 12, 2007 SmOke_N said: After reading this, and posting, I played with that very idea... I got no where with it though. Thanks for trying SmOke_N. I suppose it's a question for the developers. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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