tobias7 Posted August 13, 2007 Share Posted August 13, 2007 Hello, I've been working on a program where I want a function to return a few values in one container-like variable. In C, I would've done this with a struct, but I'm not sure of the proper way to do this in AutoIt. So far, I have noticed two options. I can use an array of variants, with variants possibly being different types, which seems discouraged in the help section, or I can use DllCreateStruct to create a struct that I can use myself, but it seems that DllStructs are meant to be used for working with dlls. Thanks for any info in advance! Link to comment Share on other sites More sharing options...
gamerman2360 Posted August 13, 2007 Share Posted August 13, 2007 (edited) I've seen the DllStruct functions used for things other than Dlls. I recommend using the DllStruct method. If you make a function to iterate over an array you would lose a bit to having autoit evaluate all those tokens(keywords/functions/operators) as it's doing the loop : \. Edited August 13, 2007 by gamerman2360 Link to comment Share on other sites More sharing options...
The Kandie Man Posted August 13, 2007 Share Posted August 13, 2007 AutoIt only supports one datatype, variant. So don't feel that you can't return the data as an array with all different datatypes in its various elements. As long as you do it in an organized fashion, you should be fine. The reason this is discouraged in the help file is probably because putting all different datatypes into an array can be really confusing to beginners. Assuming that you have worked with C, you should probably be fine in the organization department. As long as you properly name your array and keep track of which elements are of which datatype, you shouldn't have any problems. You can't get errors in autoit from using an incorrect dataype because as I mentioned earlier, AutoIt only supports one datatype. Implicit conversion of datatypes is ok to do in AutoIt. As you said, DllStructs are another way to go, but they are really only supposed to be used for Dlls and since you don't seem to be using a dll, I would recommend that you return an array. I don't see the point in over complicating your script by using dll structs when you don't have to. I hope I have helped you in reaching your decision. - 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 Link to comment Share on other sites More sharing options...
tobias7 Posted August 13, 2007 Author Share Posted August 13, 2007 Thank you guys very much for your help. 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