BoundC Function

Purpose

bounds test

Syntax

Card = BoundC(n)

Card = BoundCard(n)

n: integer expression

Description

The BoundC(n) function tests if the parameter n fits in an unsigned word (Card). This means that when n < 0 or n > 65535 an error message is reported. Otherwise n is returned unchanged.

Example

Local a&, b% = 20000, addr% = V:a&

DPoke V:a&, BoundC(b%) // Checks that b% will fit in a Card/Word

Print a&               // Prints 20000

b% = 212000

DPoke V:a&, b%         // Not checking size of b% leads to...

Print a&               // ... a& = 15392 as only first 16 bits passed

DPoke V:a&, BoundC(b%) // This will flag up the error

// or simply..

~BoundCard(b%)

Remarks

The BoundC() function serves to find program errors by early discovery of any range violations. BoundCard is a synonym.

See Also

BoundB(), BoundW(), Bound()

{Created by Sjouke Hamstra; Last updated: 24/09/2014 by James Gaite}