Navigation: ABC Library Reference > ErrorClass > ErrorClass Methods >====== SetKey (set the substitution value of the %Key macro) ====== | |
SetKey( keyname )
SetKey | Sets the substitution value of the %Key macro. |
keyname | A string constant, variable, EQUATE, or expression that indicates which key produced the error. |
The SetKey method sets the substitution value of the %Key macro. This value replaces any %Key symbols within the error message text.
Implementation:
Assigns the keyname parameter to the ErrorClass.KeyName property.
Example:
CASE ERRORCODE()
OF NoError
SELF.AutoIncDone = 0
RETURN Level:Benign
OF DupKeyErr
IF HandleError
IF ~SELF.HasAutoInc
GET(SELF.File,0) ! Flag for DUPLICATE function
END
LOOP I = 1 TO RECORDS(SELF.Keys)
GET(SELF.Keys,I)
IF DUPLICATE(SELF.Keys.Key)
SELF.Errors.SetKey(CHOOSE(CLIP(SELF.Keys.Description)<;>'',|
CLIP(SELF.Keys.Description),SELF.Keys.Key{PROP:NAME}))
SELF.ThrowMessage(Msg:DuplicateKey,SELF.Keys.Description)
RETURN Level:Notify
END
END
ELSE
SELF.SetError(Msg:DuplicateKey)
END
ELSE
SELF.SetError(Msg:AddFailed)
IF HandleError
RETURN SELF.Throw()
END
END
RETURN Level:Notify
See Also: KeyName