Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
M.Error = ERROR()
Message
From
04/06/2013 15:29:02
Thomas Ganss (Online)
Main Trend
Frankfurt, Germany
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01575604
Message ID:
01575625
Views:
48
Why not try to catch with the syntax newer and intended ;-))


>In some legacy code there's a function SafeCmd() to execute some commandline and do this safely. If it fails it returns an error number. It always worked well, until recently. The command "use xxxx exclusive alias xxxx" correctly returns error 1705 (access denied) if the table is already opened by some other application. However, in another routine a similar call incorrectly returns error 0.
>
>I could repair the routine by making variable m.error PRIVATE instead of LOCAL.
>Another way was to rename m.error to e.g. m.lnError (and keep it local).
>
>My hunch is that, under (for me obscure) circumstances, the ON ERROR handling is occurring OUT OF THE LOCAL SCOPE (where it is not out of the private scope). Or that VFP internally can get confused when processing: m.Error = ERROR()
>
>Who's got a clue to what may be the problem here? I'm not so much interested in a solution (actually, we'll gonna use the array from AERROR instead), but more in the how, why and when of this quircky behavior.
>
>
FUNCTION SafeCmd
>	LPARAMETER m.Command
>
>	local m.Error, m.OnError
>*	private m.Error, m.OnError
>
>	m.OnError = ON( 'ERROR' )
>	m.Error = 0
>
>	ON ERROR m.Error = ERROR()
>	&Command
>	ON ERROR &OnError
>
>	RETURN m.Error
Previous
Reply
Map
View

Click here to load this message in the networking platform