If a public or private variable already exists with the same name, declaring it private or local allows you use the same named variable without affecting the value or data type of the pre-existing variable when the procedure exits.As far as setting a standard that all variables beginning with "g" should be considered global/private, you can set your own standard and do that now with the existing VFP. Just document it as such and use it. Personally I use the _underscore before a variable name to indicate that it is a global variable (public or private). And as stated in my original post, 'These "Public" variables are used and treated much like "Reserve words" like "_pageno" and "_tally" in VFP. They are very well documented so that everyone involved is aware that they exist and how they are to be used.' I use a few global variables as a sort of extension to the standard VFP system variables.
LOCAL lcMsg IF this.value = .t. lcMsg = "Yes, it's true." ENDIF WAIT WINDOW lcMsg NOWAIT>As you'll probably notice, it's buggy code, for lcMsg won't get declared properly if this.value is false. Conclusion: We should avoid the usage of IF, for it introduces buggy code practices! Right?!
LOCAL lcMsg lcMsg = iif(type("this.value") = "L" .and. this.value = .t.; ,"Yes, it's true.","No it's false") WAIT WINDOW lcMsg NOWAIT or LOCAL lcMsg if type("this.value") = "L" .and. this.value = .t. lcMsg = "Yes, it's true." else lcMsg = "No it's false" endif WAIT WINDOW lcMsg NOWAIT or LOCAL lcMsg if type("this.value") = "L" if this.value = .t. lcMsg = "Yes, it's true." else lcMsg = "No it's false" endif else lcMsg = "Invalid value" endif WAIT WINDOW lcMsg NOWAITTo make it clear, I have no problem using public, private, or local variables. They are included in VFP for a reason, perhaps just legacy code or perhaps because with proper application, they can solve some programming issues. I think that the key is proper use and declaration of all variables, comment your code and document what you do and why you do it.