Questions about passing parameters

Everything else that doesn't fall into one of the other PB categories.
Stefke28
User
User
Posts: 11
Joined: Thu Jul 15, 2004 9:06 am
Location: BELGIUM

Questions about passing parameters

Post by Stefke28 »

Dear Support

1. How are passed the parameters standard in PureBASIC?

2. How do I give byref through in pure basic ?

3. How can I get the memory address to an pointer in PureBASIC ?

Thanks for your answer before

Stephane
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

3. How can I get the memory address to an pointer in PureBASIC ?
You put @ in the front of it.

from the manual:
To find the address of a variable in your code, you use the at symbol (@).
Why dont you go read the manual. Most of your questions is in there.
Stefke28
User
User
Posts: 11
Joined: Thu Jul 15, 2004 9:06 am
Location: BELGIUM

Post by Stefke28 »

And what about the questions 1 and 2 ?

Thanks
Stephane
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

In purebasic paramaters are always passed by value, on the stack in the standard c manner.

Pointer are dealt with explicitly, and the langauge does not attempt to obscure them from you through syntax.

When you pass a pointer to a structure, you are passing a pointer to a structure, the address at which that structure is held, which is a long. There is none of this obfuscating ByRef nonsense.
akee
Enthusiast
Enthusiast
Posts: 496
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

Post by akee »

i was asking the same question about ByRef and searched the forums... anyway some experimenting yielded this result.

Code: Select all

Procedure morph(*varbyref)
  PokeS(*varbyref, "outside has been changed")
EndProcedure

outside.s = "ok"

Debug outside
morph(@outside)
Debug outside
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

akee,

Be careful poking those strings

Code: Select all



Procedure morph(*varbyref)
  PokeS(*varbyref, "outside has been changed")
EndProcedure

outside.s = "ok"
after.s = "not ok"

Debug outside
Debug after
morph(@outside)
Debug outside 
Debug after

Post Reply