jvanegmond Posted March 20, 2007 Posted March 20, 2007 (edited) I am trying to use structs just like you use an array, and I've succeeded in doing so. Only when I try to create a 'multidimensional' struct (I know this is bad terminology) it fails. What is the proper way to do this? Here's an example of what I'm trying to ask: Dim $monkey Struct $monkey char legs[128] char arms[128] EndStruct Struct $monkey.legs ;error starts here. char feet[128] EndStruct $monkey.legs = "Present." $monkey.legs.feet = "Left is missing" ;this is what I want to accomplish $monkey.arms = "Lost em in WW2." MsgBox(0, "$monkey.legs", $monkey.legs) MsgBox(0, "$monkey.legs.feet", $monkey.legs.feet) ;this too. MsgBox(0, "$monkey.arms", $monkey.arms) Naturally errors out. Edited March 20, 2007 by Manadar github.com/jvanegmond
PaulIA Posted March 20, 2007 Posted March 20, 2007 I am trying to use structs just like you use an array, and I've succeeded in doing so. Only when I try to create a 'multidimensional' struct (I know this is bad terminology) it fails. What is the proper way to do this? Here's an example of what I'm trying to ask: Dim $monkey Struct $monkey char legs[128] char arms[128] EndStruct Struct $monkey.legs ;error starts here. char feet[128] EndStruct $monkey.legs = "Present." $monkey.legs.feet = "Left is missing" ;this is what I want to accomplish $monkey.arms = "Lost em in WW2." MsgBox(0, "$monkey.legs", $monkey.legs) MsgBox(0, "$monkey.legs.feet", $monkey.legs.feet) ;this too. MsgBox(0, "$monkey.arms", $monkey.arms) Naturally errors out.Might want to look at this post by Valik. The new Struct keyword was never intended to be used as a replacement for arrays. The fact that you can pervert it into a one dimensional array is an unintended side effect. Auto3Lib: A library of over 1200 functions for AutoIt
jvanegmond Posted March 20, 2007 Author Posted March 20, 2007 Might want to look at this post by Valik. The new Struct keyword was never intended to be used as a replacement for arrays. The fact that you can pervert it into a one dimensional array is an unintended side effect.I read his posts, but thanks for stating it more clearly. Besides, I'm afraid of anything Valik says anyway.. so I don't dare believe him. I'll continue programming in arrays. github.com/jvanegmond
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