Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 11th May 2008 13:57
I am a little confused about this one .... the help files say that the GLOBAL command will make your variables available throughout the entire program ... but aren\'t they available anyway without this command ??? could someone please shed some light over here ? thanks

Could you help me treat my injured Dino-Fly ?
Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 11th May 2008 14:32
hmm what do you mean ??? inside the same function, a local variable disappears ?? sorry but I get confused cause I never actually used a function in DBPro ... only in Pascal or Delphi languages can you please give me a very very small example ??? I appreciate it

Could you help me treat my injured Dino-Fly ?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 11th May 2008 15:38
Think of functions as mini-programs. By default, any variable you use within a function is local to that function, even if it uses the same name as a variable you used outside. By declaring the variable as global, they are the same variable.

Try this code, first running it as-is, then running it after putting the word 'global' at the start of the first line and see the effect:


Thought I don't understand why you don't know what's going on when Delphi/Pascal use almost exactly the same system

Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 12th May 2008 17:32
yeah, they do. it's just that the help files in DBPro made me think it's different but you and WindowsKiller made 2 excellent examples which have proven me I was right in the first place thanks a lot guys !!! By the sound of the help files, I thought that in DBPro, globals could only be created in subroutines like functions or procedures, which was more than weird silly me ... thanks again !!!

Could you help me treat my injured Dino-Fly ?

Login to post a reply

Server time is: 2024-09-27 14:27:59
Your offset time is: 2024-09-27 14:27:59