Jump to content

Struct ... EndStruct


Recommended Posts

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 by Manadar
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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. :whistle: I'll continue programming in arrays.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...