ARRAY()

From Lianjapedia
Revision as of 13:11, 5 December 2017 by Barrymavin (Talk | contribs)

Jump to: navigation, search

Purpose

Function to create a dynamic array

Syntax

ARRAY([<element value> | <element name> => <element value> [,...]])

See Also

AADD(), AAVERAGE(), ACOPY(), ADEL(), ADESC(), ADIR(), AELEMENT(), AFIELDS(), AFILL(), AINS(), ALEN(), AMAX(), AMIN(), APPEND FROM ARRAY, ASIZE(), ASORT(), ASTORE(), ASTRING(), ASUBSCRIPT(), ASUM(), COPY TO ARRAY, DECLARE, DIMENSION, GATHER, GETMEMBER(), GETPARAMETER(), IN_ARRAY(), IS_ARRAY(), LOCAL, NAMESPACE, NAMESPACE(), PRIVATE, PUBLIC, RELEASE, RESTORE, SAVE, SCATTER, SET EXACT

Description

The ARRAY() function is used to create a dynamic array. Elements are declared as a comma-separated list. Elements can be values only, <element value>, in which case they are given an automatically generated name: 00000001, 00000002 ... Element names can be specified using the <element name> => <element value> syntax. Multi-dimensional arrays can be created by using the ARRAY() function in the <element value> definition.


Example

customer = array("custname" => "A Buyer Ltd.", ;
  "currentorder" => array("ord_id" => "00001", "ord_date" => date(),"ord_total" => 1599,;
  "orderitems" =>  array("10 reams A4 paper","500 business cards",;
                         "500 black ballpoint pens")))
display memory
 
Memory Variables:
------------------------
CUSTOMER                         Dynamic array (refptr ARRAY, refcnt 1)
.CUSTNAME                          Character 'A Buyer Ltd.'
.CURRENTORDER                     Dynamic array (refptr ARRAY, refcnt 0)
 .ORD_ID                            Character '00001'
 .ORD_DATE                          Date 11/04/2009
 .ORD_TOTAL                         Numeric 1599  (1599.000000000)
 .ORDERITEMS                       Dynamic array (refptr ARRAY, refcnt 0)
  .00000001                          Character '10 reams A4 paper'
  .00000002                          Character '500 business cards'
  .00000003                          Character '500 black ballpoint pens'
 
Total of 10 variables defined and 784 bytes used.