LBOUND Lower boundary of an Array. A work-around

Modified on 2016/12/17 19:55 by CaptainBoing — Categorized as: Arrays

LBOUND() returns the number of the lowest array element. It is common in the Microsoft Basics and provides dimension information for the planned (but never implimented) method of defining an array to have dimensions starting at any positive integer - consequently it returns the OPTION BASE argument. It is difficult to emulate because of the problem of not knowing the type of array passed in to any argument.

The easiest and fastest way I have found is:

    CONST LBound=0
    OPTION BASE LBound

... which is a tiny overhead but not a proper emulation.

I suspect there are probably other methods surrounding PEEK and the VAR tables but I have not explored these.