Is there a function that is the inverse of Define, Global, etc. ? (was: small and quick question)
Posted: Sat Aug 03, 2024 3:12 pm
Hi, all.
We have Define to declare variable etc. and Defined for check / determine / found it. My question is this:
Is there a function that is the inverse of Define, Global, etc. ?
In other words, I want that the program, at a certain stage, forgot about the existence of a previously declared variable. Then global variables won't seem so scary, right ?
Has anyone thought about it or I just don't know about it ?
Okay. Here's a micro-example:
Thus, a global variable exists only in a separate section of the program.
Please, let's not argue whether this is correct. I'm interested in this possibility itself.
Thank you in advance.
We have Define to declare variable etc. and Defined for check / determine / found it. My question is this:
Is there a function that is the inverse of Define, Global, etc. ?
In other words, I want that the program, at a certain stage, forgot about the existence of a previously declared variable. Then global variables won't seem so scary, right ?
Has anyone thought about it or I just don't know about it ?
Okay. Here's a micro-example:
Code: Select all
EnableExplicit
Global *mem = AllocateMemory(100)
Procedure SomeProc()
; do something
If Defined(*mem, #PB_Variable)
Debug "Okay. I see that a variable named '*mem' already exists."
Debug "Now I want that the program to forgot about this variable, but how ?"
Debug "Of course, the previously requested memory must be freed first."
FreeMemory(*mem)
Debug ""
Debug "Probably also need to clear the pointer itself"
*mem = #Null
EndIf
EndProcedure
SomeProc()
If Defined(*mem, #PB_Variable)
Debug "As you can see, the variable still exists / is recognized by the program :("
EndIfPlease, let's not argue whether this is correct. I'm interested in this possibility itself.
Thank you in advance.