Topic Path: Symbol Reference > Classes > EIdException Class > EIdException Methods > IfNotInRange Method
EIdException.IfNotInRange Method

Raises an instance of the exception when the value is not in the specified range.

class procedure IfNotInRange(
    const AValue: Integer; 
    const AMin: Integer; 
    const AMax: Integer; 
    const AMsg: string = ''
Value to check for the minimum and maximum range values.
Minimum value for the range check.
Maximum value for the range check.
Exception message text to assign to the exception instance. 

IfNotInRange is a class procedure used to raise an instance of the exception class when the value in AValue is not in the range specified by AMin and AMax. When the value in AValue is not in the specified range, IfNotInRange calls Toss with the value in AMsg to raise the exception class instance. 

As a class method, IfNotInRange can be called without creating a prior instance of the exception class.

Using class methods in an Indy Exception descendant.

  EIdException.IfNotAssigned(AnObject, 'Object has not been created.');

  EIdException.IfAssigned(AnObject.Data, 'Object already has data.');

    'Object connection has closed before completion.');

    'Object connection is not open.');

  EIdException.IfNotInRange(AnObject.Port, 30000, 39999,
    'Object port number is invalid for this protocol.');

  // no exception raised... continue processing.
Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.