Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Opening all dbfs in a directory
Message
De
19/10/2013 12:48:46
 
 
À
19/10/2013 08:35:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01585571
Message ID:
01585856
Vues:
77
>Rick
>it is bad habit/coding to use a global vfp setting without resetting it to its previous.
>The use of 'ON ERROR' in this function as you advertize should be recoded to
>my opinion.
>Rgds,
>Koen


In that case, you can change "ON ERROR" to "DO setMyStandardOnErrorRoutine".


-----
Or, if you don't maintain a single standard ON ERROR handler, you can create a push/pop system:
pushOnError("INSERT INTO badTables VALUES(laDbfs[lnI,1], MESSAGE())")
FOR lnI = 1 TO ALEN(laDbfs,1)
    USE (laDbfs[lnI,1])
NEXT
popOnError()


* And then include these two functions somewhere in your application's stored procedures
FUNCTION pushOnError
LPARAMETERS pcNewOnError
    * Store the old
    IF TYPE("gaErrorStack[1]") != "C"
        PUBLIC gaErrorStack
        DIMENSION gaErrorStack[1]
    ELSE
        DIMENSION gaErrorStack[ALEN(gaErrorStack,1) + 1]
    ENDIF
    gaErrorStack[ALEN(gaErrorStack,1)] = ON("ERROR")

    * If they specified a new on error condition, set it up
    IF TYPE("pcNewOnError") = "C"
        ON ERROR &pcNewOnError
    ENDIF


FUNCTION popOnError
LOCAL lcError
    * Restore what previously existed, if there is any
    IF TYPE("gaErrorStack[1]") = "C"
        lcError = gaErrorStack[ALEN(gaErrorStack,1)]
        IF ALEN(gaErrorStack,1) > 1
            DIMENSION gaErrorStack[ALEN(gaErrorStack,1) - 1]
        ELSE
            RELEASE gaErrorStack
        ENDIF
        ON ERROR &lcError
    ELSE
        ON ERROR
    ENDIF
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform