Table of Contents
How can I get rid of those PUBLIC variables ?
function dPublic( cVarName, xNewValue )
local xOldValue := nil
local lVarExist := .F.
local nCounter
// If cVarName is a string, then proceed
if valType( cVarName ) == "C"
cVarName := upper( cVarName )
// Searching in the Pseudo-Variable List
for nCounter := 1 to len( _dPublic_ )
if _dPublic_[ nCounter ][ PUB_NAME ] == cVarName
// If found, then retrieve the current value into xOldValue
xOldValue := _dPublic_[ nCounter ][ PUB_VALUE ]
lVarExist := .T.
// If there is a new value passed, then assign it
if pCount() == 2
_dPublic_[ nCounter ][ PUB_VALUE ] := xNewValue
endif
endif
next
// Check if it is a new variable
if (! lVarExist) .and. pCount() == 2
aAdd( _dPublic_, { cVarName, xNewValue } )
endif
endif
return xOldValue
Download dPublic.prg now