$ArrayCheck directive

Purpose

A code optimization directive which can be used to switch off or turn back on array boundary checking.

Syntax

$ArrayCheck[On | Off]
$ArrayChk[On | Off]

Description

This directive can be used to temporarily disable the checking in a portion of the code. $ArrayCheckOff disables the checking of array boundaries. $ArrayCheckOn enables the checking again. The code in between these two directives will not protected against array boundary overflow.

For finished programs, checking of array boundaries with each array access may not be considered necessary and, as it takes additional code steps and requires extra execution time to provide array index checking, it may be beneficial to switch it off. The default setting for array index checking is controlled in the Compiler Properties dialog box but always keep in mind that the ArrayCheck directive overrides this default setting.

Example

$ArrayCheckOff   ' Disable boundary checking

Dim arInt%(1)

' Assign a value to the third element (array starts at element 0)

' Since error checking is disabled the program doesn't report an error.

arInt%(2) = 1 : Print "No Error"

$ArrayChkOn      ' Enable checking again

' The following code uses array checking once again

arInt%(2) = 1    ' Causes an 'Array-Bounds-Exceeded' error

Remarks

ArrayCheckOn is synonymous with ArrayChkOn, as ArrayCheckOff is with ArrayChkOff.

See Also

$AutoPost, $For, $Obj, $Step

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