I used structured arrays a lot! No I mean A LOT!
In fact, I generally have a class called FixedLookups that contains several Hardcoded Structured Arrays for things that are necessarily user configurable, but still easier for me to code a combo box using a structured array instead of hardcoding into control properties via the IDE.
That Class has a common Structure:
And then a number of arrays declared based on that structure, like this:
Then in the Constructor for the class I have code like this to populate the array.
Well it recently occurred to be, that WX allows you to specify an entire Array as one parameter using a “special” short hand code, by surrounding it with [].
So now those 8 lines of code, get replaced by 2 lines of code.
Much cleaner and easier to read. Obviously I wouldn’t use this for a complex array with a lot of fields, but very handy for this simple 2 field array.
Now, back to your regular schedule program….
Just a reminder if you are going to use the:
ArrayAdd(arrDelimiter,[“,”,”Comma (,)”])
and you have a few declared variables within the strLookup, then you must declared the values in the ArrayAdd in order of how you declared the variables in the strLookup structure.
The reason for pointing this out is, if you change the order of any of the variables in the strLookup structure.You then need to hunt down all the places that you used this method, which is a draw back, as the IDE does not pick it up.
So if you use the “many lines” method you will not have this problem, as it will automatically be correct if the names of the variables did not change. And if it did change, then the IDE will pick it up nicely for you.
Like Uncle Pete says, it is very handy for a very few variables in a structure..
LikeLike
Great Point Wolfgang
LikeLike
hi,
I just happened to stumble upon your site.
I’m from Canada and didn’t know there were some Wx developpers in the US with blogs like this.
Thanks to Google … now I know!
If you don’t mind my “intrusion”, let met suggest another possible simplification 🙂
Some of you might like this.
seeya 🙂
barnacker
LikeLike
hi,
I just happened to stumble upon your site.
I’m from Canada and didn’t know there were some Wx developpers in the US with blogs like this.
Thanks to Google … now I know!
If you don’t mind my “intrusion”, let met suggest another possible simplification 🙂
Some of you might like this. (see picture)
seeya 🙂
barnacker
LikeLike
Barnacker, we have a Google+ community “WxLIVE – US”
We also have a Skype chat group, contact me via skype (PeteHalsted) and I can add you to the skype group if you like
LikeLike
(sorry disqus bug)
LikeLike
Good morning, I’m using a structured array to store information, but everytime I add some values with arrayaddline, it adds them and then deletes it, so my array is always empty. What can I do to solve this?
LikeLike
I rarely use ArrayAddLine with a structured array, and would have to see your code to know specifically what they issue might be.
Generally with a structured array I would do something like:
MyStructure is structure
Field1 is int
Field2 is string
END
MyRecord is MyStructure
MyArray is array of MyStructure
MyRecord.Field1 = 1
MyRecord.Field2 = “XYZ”
ArrayAdd(MyArray,MyRecord)
ArrayAddLine would would be like this instead:
ArrayAddLine(MyArray,1,”XYZ”)
BTW, this is the type of issue that we created WXperts.com for. If you are having a specific issue with some code in your project/application, per incident support can get you help and an answer quickly and getting you moving forward with your project.
LikeLike
Thanks a lot! I would check WXperts.com and will try ArrayAdd instead
LikeLike