Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- RLIB 3.0a Reference - <b>function:</b> adim2() http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Function:    ADIM2()

Purpose:     Formulate a two dimension reference to a linear array.

Syntax:      ADIM2( row, col, numcols )

Arguments:   row         - Numeric row of the two dimensional array

             col         - Numeric column of the two dimensional array

             numcols     - Number of columns in the two dimensional array

Returns:     A linear number corresponding to the array element number
             that would be located in a two dimensional array at the
             positions row, column.

Description: Functions like ADIM2() have been implemented many ways, this
             one allows any array to be referenced by explicitly stating
             the number of columns rather that setting up a PUBLIC
             variable which limits an application to only one two
             dimension array.

Notes:       To implement a pseudo two-dimensional array in Clipper Summer
             '87, the Clipper manual suggests that you declare a PUBLIC
             variable named COLS so that the function will know how many
             columns are in the array.  This limits access to only one
             pseudo two dimensional array at a time since the example
             function explicitly references the PUBLIC variable named
             COLS.  By using ADIM2(), and passing the number of columns as
             a parameter, you can use ADIM2() to access several two
             dimensional arrays simultaneously.

Example:     *-- set up a matrix array for small spreadsheet with 100 rows
             *-- by 20 columns
             DECLARE spread[ 100 * 20 ]

             *-- simulate a Data Fill down, from 1 to 2000
             x = 1
             FOR col = 1 TO 20
                FOR row = 1 TO 100
                   spread[ ADIM2(row,col,20) ] = x
                   x = x + 1
                NEXT row
             NEXT col

Source:      RL_ADIM2.PRG

See also:    ALIST()

See Also: ALIST()

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