User Tools

Site Tools


setkey_set_the_substitution_value_of_the_key_macro_.htm
Navigation:  ABC Library Reference > ErrorClass > ErrorClass Methods >====== SetKey (set the substitution value of the %Key macro) C6H0009.jpg ====== Previous pageReturn to chapter overviewNext page

SetKey( keyname )

blk2blue.jpg

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

setkey_set_the_substitution_value_of_the_key_macro_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1