LPARAMETERS cVar LOCAL lRet, cSafety IF VARTYPE(cVar) = "C" cSafety = SET("SAFETY") SET SAFETY OFF * Some buisiness processing lRet = SomeBusinessCondition AND DoSomething() SET SAFETY &lcSafety. ENDIF RETURN lRetor with the use of the pushup class
LPARAMETERS cVar LOCAL lRet, oSafety IF VARTYPE(cVar) = "C" oSafety = CreateObject("PushPop","SAFETY","OFF") * Some buisiness processing lRet = SomeBusinessCondition AND DoSomething() ENDIF RETURN lRetPersonally (Yes I agree some might beg to differ) I find this much more readable than your example where the procedure can be exited at three different point.
LPARAMETERS m.tcVar >IF VARTYPE(m.tcVar) # "C" > RETURN .F. >ENDIF >LOCAL m.lcSafety >m.lcSafety = SET("SAFETY") >SET SAFETY OFF >* ... some processing >IF somebusinesscondition = .F. > SET SAFETY &lcSafety. && You have to remember to reset it here. > RETURN .F. >ENDIF >DO SOMETHING >SET SAFETY &lcSafety. >RETURN>
LPARAMETERS m.tcVar >IF VARTYPE(m.tcVar)#"C" > RETURN .F. >ENDIF >LOCAL m.loSafety >m.loSafety = CreateObject("PushPop","SAFETY","OFF") >* ... some processing >IF somebusinesscondition = .F. > RETURN .F. && The pushpop class will reset here. >ENDIF >DO SOMETHING >RETURN && The pushpop class will reset here.