cappy2112 Posted December 31, 2005 Share Posted December 31, 2005 Does AutoIt support any Container Objectrs, like a Class or Structure? I'm not after anything fancy like C++ but would like to pass one object (or pointer) which contains multiple values like WindowTitle, WindowText, ControlID. I use these a lot, and would like to have a simplified way of passing them instead of having to pass 3 vars to many functions. I Could use an Array, I just don't like it :-) Link to comment Share on other sites More sharing options...
LxP Posted December 31, 2005 Share Posted December 31, 2005 (edited) You've mentioned that you don't like arrays, however you may not have used them in the fashion below:; Define unique constants Global Const $Name = 0 Global Const $Address = 1 Global Const $Phone = 2 Global Const $DOB = 3 Local $Person[4] $Person[$Name] = 'Alex' $Person[$Address] = 'Melbourne' $Person[$Phone] = '183 1000' $Person[$DOB] = 'BC' MsgBox(0x40, "Alex's address", $Person[$Address])Edit: If you're using the beta then you may also want to check out DLLStructCreate(). Edited December 31, 2005 by LxP Link to comment Share on other sites More sharing options...
Valik Posted December 31, 2005 Share Posted December 31, 2005 You've mentioned that you don't like arrays, however you may not have used them in the fashion below: ; Define unique constants Global Const $Name = 0 Global Const $Address = 1 Global Const $Phone = 2 Global Const $DOB = 3 Local $Person[4] $Person[$Name] = 'Alex' $Person[$Address] = 'Melbourne' $Person[$Phone] = '183 1000' $Person[$DOB] = 'BC' MsgBox(0x40, "Alex's address", $Person[$Address]) Edit: If you're using the beta then you may also want to check out DLLStructCreate().Tsk tsk, Alex! You demonstrate the exact reason I added Enum to the language but you didn't use it: Enum $NAME, $ADDRESS, $PHONE, $DOB, $MAX Local $Person[$MAX] $Person[$NAME]='Alex' $Person[$ADDRESS] = 'Melbourne' $Person[$PHONE] = '183 1000' $Person[$DOB] = 'BC' Link to comment Share on other sites More sharing options...
MHz Posted December 31, 2005 Share Posted December 31, 2005 A sweet anxwer Valik. Where did this Enum come from? It is indeed refreshing. No response needed Link to comment Share on other sites More sharing options...
Valik Posted December 31, 2005 Share Posted December 31, 2005 A sweet anxwer Valik. Where did this Enum come from? It is indeed refreshing. No response needed May I (correctly) infer from this comment that you (and presumably Alex, as well) were not aware of Enum? Or was it something you knew about but had never seen a practical example of? Link to comment Share on other sites More sharing options...
MHz Posted December 31, 2005 Share Posted December 31, 2005 Enum seems more of a database type of of variable declaration for usage which I have little use of at majority of times so is why I have little use of remembering, but is nice to see someone bring it up at times when needed. Everybody has their own purpose and needs for different items. Link to comment Share on other sites More sharing options...
cappy2112 Posted December 31, 2005 Author Share Posted December 31, 2005 You've mentioned that you don't like arrays, however you may not have used them in the fashion below: ; Define unique constants Global Const $Name = 0 Global Const $Address = 1 Global Const $Phone = 2 Global Const $DOB = 3 Local $Person[4] $Person[$Name] = 'Alex' $Person[$Address] = 'Melbourne' $Person[$Phone] = '183 1000' $Person[$DOB] = 'BC' MsgBox(0x40, "Alex's address", $Person[$Address]) Edit: If you're using the beta then you may also want to check out DLLStructCreate(). You are right- as usual :-) This usage of arrays looks like a Python dictionary (which is very cool, indeed) This will make argument passing much better. thanks! Link to comment Share on other sites More sharing options...
LxP Posted December 31, 2005 Share Posted December 31, 2005 Tsk tsk, Alex! You demonstrate the exact reason I added Enum to the language but you didn't use it:ยทยทยทActually, I'm not sure now why I didn't use Enum. I seemed to use it the last time I wrote out code for this idea (and look at how eerily similar that code is...). Link to comment Share on other sites More sharing options...
Valik Posted January 1, 2006 Share Posted January 1, 2006 (edited) Eerie, indeed.May I recommend in the future you also demonstrate the use of the $MAX parameter. I've found that it allows for writing much cleaner code since you can add new elements to the array without having to touch existing code.Edit: To be clear, I mean demonstrate the usage of a parameter which is always at the tail end of the Enum which means it is perfect for use as the size of an array initialized. My above wording makes it sound too much like there is some special magical parameter or something associated with Enum which is not what I want to convey. Edited January 1, 2006 by Valik Link to comment Share on other sites More sharing options...
LxP Posted January 1, 2006 Share Posted January 1, 2006 I like that idea very much. I noticed that you did it in the code that you posted earlier. 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