Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>dim2() array addressing with 2-dimensions apndxj.prg</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Dim2()         Array addressing with 2-dimensions      Apndxj.prg


Syntax:        Dim2(<expN1>, <expN2>)

Argument:      <expN1> is the row index.

               <expN2> is the column index.

Returns:       A numeric value that is the actual index into the array.

Notes:       . Clipper only supports one-dimensional arrays.  You can,
               however, emulate two-dimensional arrays using Dim2().
               This user-defined function provides the
               position-allocator mechanism to access an element based
               on an row and column coordinate.

             . The memory variable, "cols" must exist and contain the
               number of columns defined in the two-dimensional matrix.


----------------------------------- Example --------------------------------

   rows = 5
   cols = 2
   *
   DECLARE array[rows * cols]
   *
   array[Dim2(2, 1)] = "A single value"
   *
   ? array[Dim2(2, 1)]


--------------------------------- Source Code ------------------------------

   FUNCTION Dim2

   PARAMETERS x, y

   RETURN (((x - 1) * cols) + y)
.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson