[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
+---------------------------------+
|              AINS               |
+---------------------------------+
AINS(<array>, <expN> [,2])

-----------------------------------
Inserts element, row or column into array.
Return value - Numeric
-----------------------------------

This function inserts an element into a one-dimensional array, or a row
or column into a two-dimensional.  Inserting an element, row or column
into an array does not change the size of the array - the trailing
elements, rows or columns are shifted towards the end of the array and
the last element, row or column in the array is dropped from the array.
The newly inserted element, row or column is initialized to a logical
false (.F.).

If an element, row or column is successfully inserted, 1 is returned.

Clauses
-------

<array>
        Array into which data is inserted.

<expN>
        1-D array               element number
        2-D array               row number

2
        Indicates that <expN> is a column.

+---------------------------------+
|             Example             |
+---------------------------------+
*** SELECT or USE customer database ***
IF USED('customer')
        SELECT customer
ELSE
        USE LOCFILE('customer.dbf','DBF','Where is CUSTOMER.DBF?')
ENDIF

COUNT TO m.count
*** DIMENSION array large enough to hold data ***
DIMENSION companies[m.count,1]

COPY TO ARRAY companies FIELD Company  && Fill array

m.name = 'DataTech Inc.'

IF ASCAN(companies, m.name) = 0  && Search for company
        * Company not found - add it.
        = AINS(companies, m.count+1)
        companies[m.count+1] = m.name
ENDIF

DISPLAY MEMORY LIKE *

-----------------------------------

See Also:  ACOPY(), ADEL(), ASCAN(), ASORT()

-----------------------------------

See Also: ACOPY() ADEL() ASCAN() ASORT()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson