Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
M.Error = ERROR()
Message
De
04/06/2013 11:15:08
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
M.Error = ERROR()
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01575604
Message ID:
01575604
Vues:
94
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
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform