JCL Help:IncLimitClamp@Byte@Byte@Byte

From Project JEDI Wiki
Jump to navigationJump to search


Summary

Increments an ordinal up to limit.


Pascal

 function IncLimitClamp(var B: Byte; const Limit: Byte; const Incr: Byte = 1): Byte; overload;
function IncLimitClamp(var B: Shortint; const Limit: Shortint; const Incr: Shortint = 1): Shortint; overload;
function IncLimitClamp(var B: Smallint; const Limit: Smallint; const Incr: Smallint = 1): Smallint; overload;
function IncLimitClamp(var B: Word; const Limit: Word; const Incr: Word = 1): Word; overload;
function IncLimitClamp(var B: Integer; const Limit: Integer; const Incr: Integer = 1): Integer; overload;
function IncLimitClamp(var B: Cardinal; const Limit: Cardinal; const Incr: Cardinal = 1): Cardinal; overload;
function IncLimitClamp(var B: Int64; const Limit: Int64; const Incr: Int64 = 1): Int64; overload;


Parameters

Parameters Description
var B: Byte The value to conditionally increment.
const Limit: Byte The incrementation limit.
const Incr: Byte = 1 The amount to increment.


Return Value

B contains the incremented value if within limit, otherwise it is set to the limit value. This same value is returned as the function result.


Description

IncLimitClamp increments the specified ordinal variable by the specified value. If this increment would increase the value beyond the specified limit, the variable is clamped to the limit. For example, suppose that X equals 5, now calling IncLimitClamp(X, 10, 2) will increment X by 2 leaving it with 7 on return. However, calling IncLimitClamp(X, 10, 6) will not increment X by 6 because that would increment X beyond the limit. X is set to 10 (the limit) instead.


See Also

DecLimit IncLimit DecLimitClamp


About

Unit

JclLogic


Donator

Marcel van Brakel


Notes

If upon entry the B variable is already larger than the limit the variable is set to Limit.


Contribute to this help topic

This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page