GLBasic forum

Main forum => GLBasic - en => Topic started by: ByteByter on 2011-Aug-11

Title: Functions...?
Post by: ByteByter on 2011-Aug-11
Code (glbasic) Select

Global B;B=10

AddOne(B)
Print B,0,0
Showscreen
Mouswait

Function AddOne:A
A=A+1
endfunction


Returns 10, has GLB always been like this? Because In most languages this would modify the variable that was input into the function, changing it's value to 11, and I could have sworn GLB was not like this before.

Using GLB V10.054 Beta.
Title: Re: Functions...?
Post by: Minion on 2011-Aug-11
If you use the BYREF command, then you can alter the value, otherwise all you are throwing into the function is a copy
Title: Re: Functions...?
Post by: ByteByter on 2011-Aug-11
Quote from: Minion on 2011-Aug-11
If you use the BYREF command, then you can alter the value, otherwise all you are throwing into the function is a copy
Thanks, I feel stupid, I've been doing this for a while now, and hadn't noticed anything? Well, at least this explains a few errors I've been having with my program