Page 1 of 1
Passing Structure Arrays
Posted: Tue Jun 21, 2011 10:55 am
by coder14
I've been searching through this forum, but can't seem to find anything on this. There've been examples for arrays in structures, and even dimensioning structure arrays. But how would I pass a structure array to a procedure:
Code: Select all
Structure example
a.l
b.s
EndStructure
Dim test.example(3)
test(1)\a = 123
test(2)\b = "A B C"
sample(test())
End
Procedure sample(pass.example())
Debug pass(1)\a
Debug pass(2)\b
pass(2)\b = "D E F"
EndProcedure
This is just to illustrate the intended operation, and obviously doesn't work. Can anyone help please?
Cheers!
Re: Passing Structure Arrays
Posted: Tue Jun 21, 2011 11:15 am
by tinman
Edit: removed my post as it was incorrect and based on outdated information.
Re: Passing Structure Arrays
Posted: Tue Jun 21, 2011 11:42 am
by netmaestro
Actually your sample code works with remarkably little modification. Simply pass the array as parameter:
Code: Select all
Structure example
a.l
b.s
EndStructure
Dim test.example(3)
test(1)\a = 123
test(2)\b = "A B C"
Procedure sample(Array pass.example(1))
Debug pass(1)\a
Debug pass(2)\b
pass(2)\b = "D E F"
EndProcedure
sample(test())
sample(test())
Re: Passing Structure Arrays
Posted: Tue Jun 21, 2011 2:07 pm
by coder14
@netmaestro: Smply brilliant! You got it absolutely right. Thank you!
I tried variations of using the * and @ operators, and also using the Array keyword, but somehow didn't seem to get the right combination. Not very scientific, but that's the way I code.
Thanks to you too tinman. I didn't get a chance to try your code before you yanked it out, but I'm sure it was brilliant.
Back to my code!
Re: Passing Structure Arrays
Posted: Tue Jun 21, 2011 2:34 pm
by c4s
@coder14
Probably Procedure sample(Array pass.example(1)) confused you, at least for me it always was. Just take a look at the help for Procedure and Dim...
Re: Passing Structure Arrays
Posted: Tue Jun 21, 2011 3:33 pm
by coder14
c4s wrote:@coder14
Probably Procedure sample(Array pass.example(1)) confused you, at least for me it always was. Just take a look at the help for Procedure and Dim...
WHOA! How did I miss that? I poured through the help file like crazy and I still missed that.
I probably need a break. Thanks for the heads up - you guys are great.