Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Codebook - aerror prob
Message
 
À
11/08/1997 05:46:22
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00043959
Message ID:
00044153
Vues:
34
Prakash,
Here is the fix. I reproduce a message from the foxuser forum on Compuserve.
************
------------------------------------------------------------------
FORWARDED MESSAGE - Orig: 14-Jul-97 0:28
Subject: CB3: ERRORFIELDRULE ERRO - Msg Number #243762
From: Kevin McNeish [Oak Leaf] 104657,2113
To: JORGE M. ADAN 72643,556
Forum: FOXGANG Section: 09 - 3rd Party Products
------------------------------------------------------------------

Jorge,

name causing the error as expected, it contains the error message text. This seems to be a
bug in AERROR().>

You're right...you must be using VFP 5...Microsoft changed the return parameters in VFP
5.0...incorrectly. They did change them back again in VFP 5.0a...except not to what they
originally were in VFP 3!!!

At any rate, if you have VFP 5.0a, the following code (taken from our VFP5 Codebook for Mere
Mortals framework) should do the job for you. Are you using Ed Leafe's EBizObj? Unless he has
substantially changed the original Codebook logic, this should still work for you.

Regards,
Kevin McNeish
www.oakleafsd.com

*---------------------- Location Section ------------------------
* Library: KBizness
* Class: KBizObj
* Method: ErrorFieldRule
*----------------------- Usage Section --------------------------
*) Description:
*) This method handles failed field rule validations for
*) tables, local views and remote views. Its primary purpose
*) is to display an informative message to the user who
*) caused the error.
*)
*) NOTE: The fix applied to this method will only work under
*) VFP 5.0a and greater. VFP3 used to return the name of the
*) error field in AERROR's third parameter. VFP 5.0 simply
*) returned a copy of the error message in parameter 2.
*) VFP5.0a returns the number of the error field in AERROR's
*) fifth parameter
*
* Scope: Protected
* Parameters: None
*$ Usage: KBizObj::ErrorFieldRule()
*% Example: THIS.ErrorFieldRule()
* Returns: LOGICAL .T. by default
*--------------------- Maintenance Section ----------------------
*@ Inputs:
*@ 1. FoxPro's error handling function AERROR()
*@ 2. If a local view or table, the .DBC is used to extract
*@ the text to display when the field validation failed.
* Outputs: None
* Pre-condition Invariants:
* 1. An error occurred
* Post-condition Invariants:
* 1. If we are dealing with a local table or view then
* the user is displayed the Error Text for that
* field rule that is stored in the .DBC
* 2. If we are dealing with a remote view then the
* user sees Codebook's default field validation
* rule error message along with the name of the
* field whose rules were violated.
*? Notes: None
* Collaborating Methods: None
*-- Process:
*-- 1. Get the number of the field that caused the error
*-- 2. Get the name of the field that caused the error
*-- 3. If a field name was discovered
*-- 4. DO CASE
*-- 5. CASE the data environment is either a local view or local table
*-- 6. Get the update name of the field to retrieve the text for
*-- 7. Get the field rule error text from the .DBC
*-- OTHERWISE ( a remote view is being used )
*-- 8. Use the generic Codebook field rule fail error message
*-- and identify the name of the field that failed.
*-- ENDCASE
*-- 9. IF a field error validation message was found from the .DBC
*-- 10. Display it
*-- ENDIF
*-- 11. Set focus to the field that caused the error
* Change Log:
* CREATED Tuesday, 04/22/1997 - KJM:
* COMPLETED Tuesday, 04/22/1997 - KJM:
*
* MODIFIED 06/09/97 - KJM - Created by Jose Constant
* Added check if cursor is a local view. If so, prepend
* an "l" to the v_
************************************************************
LOCAL laError[AERROR_NUMCOLUMNS], ;
lcField, ;
lcUpdateName, ;
lcMessage, ;
lnFieldNum

lcMessage = ""
=AERROR(laError)

*----------------------------------------
*--- Get the number of the error field
*----------------------------------------
lnFieldNum = laError[5]

*--------------------------------------
*--- Get the name of the error field
*--- if it is available.
*--------------------------------------
IF TYPE('lnFieldNum') == 'N' AND NOT EMPTY(This.oBehavior.cErrorTable)
lcField = FIELD(lnFieldNum,This.oBehavior.cErrorTable)
ELSE
lcField = 'Unknown'
ENDIF

*---------------------------------
*-- If a field name was discovered
*---------------------------------
IF !ISNULL(lcField) AND !EMPTY(lcField)
DO CASE
*--------------------------------------------------
*-- Case the data environment is either a local
*-- view or a local table.
*--------------------------------------------------
CASE CURSORGETPROP("SOURCETYPE") <> DB_SRCREMOTEVIEW
*--------------------------------------------------------
*-- If current alias is a local view or table, get the
*-- update name of the field to retrieve the text for
*--------------------------------------------------------
lcUpdateName = This.oBehavior.cErrorTable + "." + lcField
*-----------------------------------------------------------------
*-- Case it is a local view, add an "l" prefix, to v_
*-----------------------------------------------------------------
IF CURSORGETPROP('SOURCETYPE') = DB_SRCLOCALVIEW
lcUpdateName = 'l' + lcUpdateName
ENDIF
*-----------------------------------------------------------------
*-- Get the text that describes the rule that failed from the .DBC
*-----------------------------------------------------------------
lcMessage = STRTRAN(DBGETPROP(lcUpdateName, "FIELD", "RULETEXT"), '"', "")
OTHERWISE
lcMessage = FIELDRULEFAIL_LOC + " " + lcField
ENDCASE
ENDIF

*----------------------------
*-- Display the error message
*----------------------------
IF !EMPTY(lcMessage)
=ErrorMsg(lcMessage)
ENDIF

*-----------------------------------------------
*-- Set focus to the field that caused the error
*-----------------------------------------------
this.SetChildFocus(lcField)

************
>Hi,
>
>I was trying to set up the codebook software . I downloaded the latest mere mortal doc from oakleafsd and found that i was having prob with VFP 5.0. After lot of going back and forth between vfp3.0b and vfp5.0a , i figured out that the problem was with aerror.
>
>On going thru my e-mail archives ( i am not premier member ), i found that u had come up with same problem some time back.
>
>Please let me know if u were able to resolve the issue, and if so how. Any other advice re codebook welcome , since i seem to be following in your footsteps.
>
>Thanx
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform