Question on how to pass a structure to a procedure

Just starting out? Need help? Post your questions and find answers here.
wayne-c
Enthusiast
Enthusiast
Posts: 335
Joined: Tue Jun 08, 2004 10:29 am
Location: Zurich, Switzerland

Question on how to pass a structure to a procedure

Post by wayne-c »

What's the difference between A and B below? Is one better than the other? The result seems equal, but behind the scenes? Thank you

Code: Select all

Structure MyStruct
	Hello$
EndStructure

Procedure Test(*Struct.MyStruct)
	Debug *Struct\Hello$
EndProcedure

Define mys.MyStruct\Hello$ = "Hello World"

; A
Test(mys)

; B
Test(@mys)
As you walk on by, Will you call my name? Or will you walk away?
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Question on how to pass a structure to a procedure

Post by Josh »

If the parameter in your procedure wants a pointer, you should always pass a pointer when calling it. Even if it works without' @', it is only guaranteed with an' @' that you also pass a pointer.

Use variant B.
sorry for my bad english
Post Reply