Page 1 of 1

Paasing a structure to a function

Posted: Sun May 25, 2003 9:40 pm
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.

Re: Paasing a structure to a function

Posted: Sun May 25, 2003 9:49 pm
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

Posted: Sun May 25, 2003 10:02 pm
by freak
Maybe you want to read this one for a better understanding...

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

Timo

Posted: Mon May 26, 2003 5:06 am
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