Paasing a structure to a function

Just starting out? Need help? Post your questions and find answers here.
twobits
User
User
Posts: 11
Joined: Thu May 22, 2003 6:53 pm

Paasing a structure to a function

Post by twobits »

Hi everyone - I have this following piece of code

Code: Select all

Structure mystruct
    anitem.l
endstructure

procedure dosomething1 ( temp.mystruct )
endprocedure

procedure dosomething2 ( *temp.mustruct )
    temp\anitem = temp\anitem + 1
endprocedure
Both of the procedures wont work, the first give me the error : Syntax error
and the second gives me the error: This variable doesnt have a 'structure'
Could somebody explain how to pass a structure to a function properly.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: Paasing a structure to a function

Post by traumatic »

"*var" and "var" are two different variables in purebasic.

this should work:

Code: Select all

procedure dosomething( *temp.mystruct )
    *temp\anitem +1
endprocedure
Good programmers don't comment their code. It was hard to write, should be hard to read.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Maybe you want to read this one for a better understanding...

viewtopic.php?p=24846&highlight=#24846

Timo
quidquid Latine dictum sit altum videtur
HarryO
User
User
Posts: 42
Joined: Wed May 07, 2003 4:25 am
Location: Palatine,IL.,USA

Post by HarryO »

twobits,

BTW, you miss-spelled the var type on the second call:

You have -

procedure dosomething2 ( *temp.mustruct )
temp\anitem = temp\anitem + 1
endprocedure

should be -

procedure dosomething2 ( *temp.mystruct )
temp\anitem = temp\anitem + 1
endprocedure

This might be onr of your issues.

HarryO
Post Reply