JCL Help:DecLimitClamp@Byte@Byte@Byte

From Project JEDI Wiki
Jump to navigationJump to search


Summary

Decrements an ordinal up to limit.


Pascal

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


Parameters

Parameters Description
var B: Byte The value to conditionally decrement.
const Limit: Byte The decrementation limit, this is inclusive.
const Decr: Byte = 1 The amount to decrement.


Return Value

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


Description

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


See Also

IncLimit DecLimit IncLimitClamp


About

Unit

JclLogic


Donator

Marcel van Brakel


Notes

If upon entry the B variable is already smaller 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