You have four ways of programming in PB:
0) Extreme relaxed
1) Verry relaxed
2) Less relaxed
3) closed (uptight?)
I choose with intend for the ZERO as the first methode but that is because i never use that, only for very short temporary code to testing code.
Zero mode, you declare NO globals no shared only protected if you have a variable INSIDE your procedure with the same name outside. All variables without a dot letter are deamed Long (the .l at the end) or otherwise declared with "Define.s" than everything without a dot letter is a string. This is good old basic in it's most relaxed way. But very prone to 'creaping' soft errors.
The first methode is using GLOBAL so every variable is seen by all procedure's . NOTE you do NOT use SHARED!! Protected is used to shield names inside proc's for variables of the same name outside the proc.
Second: Less relaxed, now you use DEFINE for ALL your variables (note you do NOT use GLOBAL) . Now in every variable is seen in the main program but NOT inside procedure's NOW we use SHARED.
3) To be even more unrelaxed we use EnableExplicit, now every variable has to be defined AND PROTECTED AND/OR SHARED. It can be hard to write but since every variable has to be declared it helps to minimize bugs due to naming errors. Personnally I use ONLY mode 3 and it keeps your program sane. It keep development short and bugs more easy to find. The kickback is to declare every 'Tom, Dick and Harry"-variable.
NOTE we do NOT ever use GLOBAL is this mode, not even to get our code working find out why we need a global to get he code working.
I hope this helps. You can see now that SHARED really has a viable function it depends on HOW, when and where to use.
Standard rule from me is: You do NOT mix Global with Shared it does work but finding faults in your code is very hard. This is NOT an error in PB but more a programmers fault. And YES i learned it the hard way. Made that error myself in two application i made. Now they are in mode 3 uptight.
PB is wonderfull is that respact that it is capable of writing code in 4 ways. Depending on you'r needs. Short and simple use mode zero. better code goes up to mode 3 (very robust).
Using mode 3 saved me more than one time from memory leaks in programs. Or (better) finding error(s) in other peoples code. no disrespect meant more an observation.
Succes in happy programming,
Jan V.
(edit: the extra note at mode 3)