Page 2 of 2
Re: Keyword 'Global' is not really useful ... use Shared
Posted: Sat Sep 09, 2006 3:07 pm
by NoahPhense
PB wrote:Do you really want all that hassle?
Yeah man... don't hassle the hoff...
- np
Re: Keyword 'Global' is not really useful ... use Shared
Posted: Tue Sep 12, 2006 2:43 am
by Amiga5k
PB wrote:> If you use Global very often (You like it?) it seems to be a bad design of your code
No it's not. I use it for variables that NEVER change, such as appname$ that
holds the name of the running exe.
Isn't another name for a variable that never changes a "Constant"?
Russell
Re: Keyword 'Global' is not really useful ... use Shared
Posted: Tue Sep 12, 2006 10:12 pm
by Henrik
Amiga5k wrote:PB wrote:> If you use Global very often (You like it?) it seems to be a bad design of your code
No it's not. I use it for variables that NEVER change, such as appname$ that
holds the name of the running exe.
Isn't another name for a variable that never changes a "Constant"?
Russell
@Amiga5k not really.
A Constant can't be defined by a variabel, whereas a global can be, and at runtime and stille never change after that, if you like.
best Henrik
Re: Keyword 'Global' is not really useful ... use Shared
Posted: Tue Sep 12, 2006 10:21 pm
by PB
> Isn't another name for a variable that never changes a "Constant"?
Yes, but only when the variable's value is already known. Observe:

Posted: Wed Sep 13, 2006 4:58 pm
by Trond
Well, there you changed it (it was null when the program started, now it's "PureBasic1.exe" or something).
Posted: Wed Sep 13, 2006 10:24 pm
by PB
> you changed it
Technically: yes, of course a variable will change once you give it an inital value.
Posted: Thu Sep 14, 2006 3:02 am
by Amiga5k
And you did say that you would "Never" change it...

Just messing with ya here, but there is a subtle difference. It could, however, be useful to allow Constants to be defined
initially with a variable - under certain rules of course (such as the example given). But I suppose in that situation you would just use a Global.
Russell
Posted: Thu Sep 14, 2006 6:21 am
by Dare
I'm not sure I see how a constant can be assigned a variable value.
Maybe special constants could be created such as #PB_ProgramFileName, but they would not be real constants. PureBasic would have to do some hidden initial code to assign the value to the Psuedo-Constant. And in such a case there would be no real gain for the programmer or the program over using the Global approach as PB outlined.