JCL Help:IncLimit@Byte@Byte@Byte

From Project JEDI Wiki
Jump to navigationJump to search


Summary

Increments an ordinal up to limit.


Pascal

 function IncLimit(var B: Byte; const Limit: Byte; const Incr: Byte = 1): Byte; overload;
function IncLimit(var B: Shortint; const Limit: Shortint; const Incr: Shortint = 1): Shortint; overload;
function IncLimit(var B: Smallint; const Limit: Smallint; const Incr: Smallint = 1): Smallint; overload;
function IncLimit(var B: Word; const Limit: Word; const Incr: Word = 1): Word; overload;
function IncLimit(var B: Integer; const Limit: Integer; const Incr: Integer = 1): Integer; overload;
function IncLimit(var B: Cardinal; const Limit: Cardinal; const Incr: Cardinal = 1): Cardinal; overload;
function IncLimit(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 contains the original value. This same value is returned as the function result.


Description

IncLimit increments the specified ordinal variable by the specified value if and only if the operation will not increment beyond the limit. For example, suppose that X equals 5, now calling IncLimit(X, 10, 2) will increment X by 2 leaving it with 7 on return. However, calling IncLimit(X, 10, 6) will not increment X by 6 because that would increment X beyond the limit. On return X still contains 5.


See Also

DecLimit DecLimitClamp IncLimitClamp


About

Unit

JclLogic


Donator

ESB Consultancy


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