# How I can delete an item …

### How I can delete an item in an array ?

This function deletes the element found at the given subscript position in the array.

All elements in the array below the given subscript position will move up one positionin the array.

Let’s try:

```?
aTest1 := { 'One', 'Two', "Tree",'Four' }
aTest := ACLONE( aTest1 )
? LEN( aTest )
AEVAL( aTest, { | c1 | QQOUT( c1, '' ) } )

```

Result :
4
One Two Four NIL
Length of array not changed, last item moved up and new last item became NIL.

```?
ASIZE( aTest, 3 )
? LEN( aTest )
?
AEVAL( aTest, { | c1 | QQOUT( c1, '' ) } )
```

Result :
3
One Two Four
Length of array changed, last item (NIL) removed

We have another possibility: a new Harbour function:

```?
aTest1 := { 'One', 'Two', "Tree",'Four' }
aTest := ACLONE( aTest1 )
? LEN( aTest )
?
AEVAL( aTest, { | c1 | QQOUT( c1, '' ) } )

```

Result :
4
One Two Four NIL
Length of array not changed, last item moved up and new last item became NIL.

And we have a third parameter : Shrink or not:

``` ?
aTest1 := { 'One', 'Two', "Tree",'Four' }
aTest := ACLONE( aTest1 )
AEVAL( aTest, { | c1 | QQOUT( c1, '' ) } )```

That’s all !

# Array Functions

 AAdd Dynamically add an element to an array AClone Duplicate an array ACopy Copy elements from one array to another ADel Delete an element form an array AEval Evaluates the subscript element of an array AFill Fill an array with a specified value AIns Insert a NIL value at an array subscript position Array Build an uninitialized array of specified length AScan Scan array elements for a specified condition ASize Adjust the size of an array ASort Sort an array ATail Returns the rightmost element of an array

# ASize()

### ASIZE()

Adjust the size of an array

Syntax

`      ASIZE(<aArray>, <nLen>) --> aTarget`

Arguments

<aArray> Name of array to be dynamically altered

<nLen> Numeric value representing the new size of <aArray>

Returns

<aTarget> an array pointer reference to <aTarget>.

Description

This function will dynamically increase or decrease the size of <aArray> by adjusting the length of the array to <nLen> subscript positions.

If the length of the array <aArray> is shortened, those former subscript positions are lost. If the length of the array is lengthened a NIL value is assigned to the new subscript position.

Examples

```      LOCAL aArray := { 1 }      // Result: aArray is { 1 }
ASize( aArray, 3 )         // Result: aArray is { 1, NIL, NIL }
ASize( aArray, 1 )         // Result: aArray is { 1 }```

Compliance

If HB_COMPAT_C53 is defined, the function generates an Error, else it will return the array itself.

Files

Library is vm

Seealso

# Array()

### ARRAY()

Create an uninitialized array of specified length

Syntax

`      ARRAY( <nElements> [, <nElements>...] ) --> aArray`

Arguments

<nElements> is the number of elements in the specified dimension.

Returns

<aArray> an array of specified dimensions.

Description

This function returns an uninitialized array with the length of <nElements>.

Nested arrays are uninitialized within the same array pointer reference if additional parameters are specified.

Establishing a memory variable with the same name as the array may destroy the original array and release the entire contents of the array. This depends, of course, on the data storage type of either the array or the variable with the same name as the array.

Examples

```      PROCEDURE Main()
LOCAL aArray := Array( 10 )
LOCAL x
FOR x := 1 TO Len( aArray )
aArray[ x ] := Array( x )
NEXT
// Result is: { { NIL }, { NIL, NIL }, ... }
RETURN```

Compliance

Clipper (array)

Files

Library is vm

Seealso

# AIns()

### AINS()

Insert a NIL value at an array subscript position.

Syntax

`      AINS( <aArray>, <nPos> ) --> aTarget`

Arguments

<aArray> Array name.

<nPos> Subscript position in <aArray>

Returns

<aTarget> an array pointer reference.

Description

This function inserts a NIL value in the array named <aArray> at the <nPos>th position.

All array elements starting with the <nPos>th position will be shifted down one subscript position in the array list and the last item in the array will be removed completely. In other words, if an array element were to be inserted at the fifth subscript position, the element previously in the fifth position would now be located at the sixth position. The length of the array <aArray> will remain unchanged.

Examples

```      LOCAL aArray := { "Harbour", "is", "Power!", "!!!" }
AIns( aArray, 4 )```

Compliance

Clipper

Files

Library is vm

Seealso

# ACopy()

### ACOPY()

Copy elements from one array to another

Syntax

`      ACOPY( <aSource>, <aTarget>, [<nStart>], [<nCount>], [<nTargetPos>] ) --> aTarget`

Arguments

<aSource> is the array to copy elements from.

<aTarget> is the array to copy elements to.

<nStart> is the beginning subscript position to copy from <aSource>

<nCount> the number of subscript elements to copy from <aSource>.

<nTargetPos> the starting subscript position in <aTarget> to copy elements to.

Returns

<aTarget> an array pointer reference

Description

This function copies array elements from <aSource> to <aTarget>.

<nStart> is the beginning element to be copied from <aSource>; the default is 1.

<nCount> is the number of elements to be copied from <aSource>; the default is the entire array.

<nTargetPos> is the subscript number in the target array, <aTarget>, to which array elements are to be copied; the default is 1

This function will copy all data types in <aSource> to <aTarget>.

If an array element in <aSource> is a pointer reference to another array, that array pointer will be copied to <aTarget>; not all subdimensions will be copied from one array to the next. This must be accomplished via the ACLONE() function.

Note: If array <aSource> is larger then <aTarget>, array elements will start copying at <nTargetPos> and continue copying until the end of array <aTarget> is reached. The ACOPY() function doesn’t append subscript positions to the target array, the size of the target array <aTarget> remains constant.

Examples

```      LOCAL nCount := 2, nStart := 1, aOne, aTwo
aOne := { "HARBOUR", " is ", "POWER"}
aTwo := { "CLIPPER", " was ", "POWER"}
ACopy( aOne, aTwo, nStart, nCount )```

Compliance

Clipper

Files

Library is vm

Seealso

ACLONE(), ADEL(), AEVAL(), AFILL(), AINS(), ASORT()

# AClone()

### ACLONE()

Duplicate a multidimensional array

Syntax

`      ACLONE(<aSource>) --> aDuplicate`

Arguments

<aSource> Name of the array to be cloned.

Returns

<aDuplicate> A new array pointer reference complete with nested array values.

Description

This function makes a complete copy of the array expressed as <aSource> and return a cloned set of array values. This provides a complete set of arrays values for all dimensions within the original array <aSource>

Examples

```      LOCAL aOne, aTwo
aOne := { "Harbour"," is ","POWER" }
aTwo := AClone( aOne )       // Result: aTwo is {"Harbour"," is ","POWER"}
aOne[ 1 ] := "The Harbour Compiler"
// Result:
// aOne is { "The Harbour Compiler", " is ", "POWER" }
// aTwo is { "Harbour"," is ","POWER" }```

Compliance

CA-Cl*pper will return NIL if the parameter is not an array.

Files

Library is vm

Seealso

# C5_Functions

``` AADD()          Add a new element to the end of an array
ABS()           Return the absolute value of a numeric expression
ACLONE()        Duplicate a nested or multidimensional array
ACOPY()         Copy elements from one array to another
ADIR()*         Fill a series of arrays with directory information
AEVAL()         Execute a code block for each element in an array
AFIELDS()*      Fill arrays with the structure of the current database file
AFILL()         Fill an array with a specified value
AINS()          Insert a NIL element into an array
ALERT()         Display a simple modal dialog box
ALIAS()         Return a specified work area alias
ALLTRIM()       Remove leading and trailing spaces from a character string
ALTD()          Invoke the CA-Clipper debugger
ARRAY()         Create an uninitialized array of specified length
ASC()           Convert a character to its ASCII value
ASCAN()         Scan an array for a value or until a block returns true (.T.)
ASIZE()         Grow or shrink an array
ASORT()         Sort an array
AT()            Return the position of a substring within a character string
ATAIL()         Return the highest numbered element of an array
BIN2I()         Convert a 16-bit signed integer to a numeric value
BIN2L()         Convert a 32-bit signed integer to a numeric value
BIN2W()         Convert a 16-bit unsigned integer to a numeric value
BOF()           Determine when beginning of file is encountered
BREAK()         Branch out of a BEGIN SEQUENCE...END construct
BROWSE()*       Browse records within a window
CDOW()          Convert a date value to a character day of the week
CHR()           Convert an ASCII code to a character value
CMONTH()        Convert a date to a character month name
COL()           Return the screen cursor column position
COLORSELECT()   Activate attribute in current color settings
CTOD()          Convert a date string to a date value
CURDIR()        Return the current DOS directory
DATE()          Return the system date as a date value
DAY()           Return the day of the month as a numeric value
DBAPPEND()      Append a new record to the database in the current work area
DBCLEARFIL()    Clear a filter condition
DBCLEARIND()    Close all indexes for the current work area
DBCLEARREL()    Clear active relations
DBCLOSEALL()    Close all occupied work areas
DBCLOSEAREA()   Close a work area
DBCOMMITALL()   Flush pending updates in all work areas
DBCREATE()      Create a database file from a database structure array
DBCREATEIND()   Create an index file
DBDELETE()      Mark a record for deletion
DBEDIT()        Browse records in a table layout
DBEVAL()        Evaluate code block for each record matching scope/condition
DBF()*          Return current alias name
DBFIELDINFO()   Return and optionally change information about a field
DBFILEGET()     Insert the contents of a field into a file
DBFILEPUT()     Insert the contents of a file into a field
DBFILTER()      Return the current filter expression as a character string
DBGOBOTTOM()    Move to the last logical record
DBGOTO()        Position record pointer to a specific identity
DBGOTOP()       Move to the first logical record
DBINFO()        Return and optionally change database file information
DBORDERINFO()   Return and optionally change order and index file information
DBRECALL()      Reinstate a record marked for deletion
DBRECORDINFO()  Return and optionally change information about a record
DBREINDEX()     Recreate all active indexes for the current work area
DBRELATION()    Return the linking expression of a specified relation
DBRLOCK()       Lock the record at the current or specified identity
DBRLOCKLIST()   Return an array of the current lock list
DBRSELECT()     Return the target work area number of a relation
DBRUNLOCK()     Release all or specified record locks
DBSEEK()        Move to the record having the specified key value
DBSELECTAR()    Change the current work area
DBSETDRIVER()   Return the database driver and optionally set a new driver
DBSETFILTER()   Set a filter condition
DBSETINDEX()    Empty orders from an order bag into the order list
DBSETORDER()    Set the controlling order
DBSETRELAT()    Relate two work areas
DBSKIP()        Move relative to the current record
DBSTRUCT()      Create an array containing the structure of a database file
DBUNLOCK()      Release all locks for the current work area
DBUNLOCKALL()   Release all locks for all work areas
DBUSEAREA()     Use a database file in a work area
DELETED()       Return the deleted status of the current record
DESCEND()       Create a descending index key value
DEVOUT()        Write a value to the current device
DEVOUTPICT()    Write a value to the current device using a picture clause
DEVPOS()        Move the cursor or printhead to a new position
DIRCHANGE()     Change the current DOS directory
DIRECTORY()     Create an array of directory and file information
DIRMAKE()       Create a directory
DIRREMOVE()     Remove a directory
DISKCHANGE()    Change the current DOS disk drive
DISKNAME()      Return the current DOS drive
DISKSPACE()     Return the space available on a specified disk
DISPBEGIN()     Begin buffering screen output
DISPBOX()       Display a box on the screen
DISPCOUNT()     Return the number of pending DISPEND() requests
DISPOUT()       Write a value to the display
DOSERROR()      Return the last DOS error number
DOW()           Convert a date value to a numeric day of the week
DTOC()          Convert a date value to a character string
DTOS()          Convert a date value to a string formatted as yyyymmdd
EMPTY()         Determine if the result of an expression is empty
EOF()           Determine when end of file is encountered
ERRORBLOCK()    Post a code block to execute when a runtime error occurs
ERRORLEVEL()    Set the CA-Clipper return code
EVAL()          Evaluate a code block
EXP()           Calculate e**x
FCLOSE()        Close an open binary file and write DOS buffers to disk
FCOUNT()        Return the number of fields in the current .dbf file
FCREATE()       Create and/or truncate a binary file to zero-length
FERASE()        Delete a file from disk
FERROR()        Test for errors after a binary file operation
FIELD()         Return a field name from the current database (.dbf) file
FIELDBLOCK()    Return a set-get code block for a given field
FIELDGET()      Retrieve the value of a field using the field position
FIELDNAME()     Return a field name from the current database (.dbf) file
FIELDPOS()      Return the position of a field in a work area
FIELDPUT()      Set the value of a field variable using the field position
FIELDWBLOCK()   Return a set-get code block for a field in a given work area
FILE()          Determine if files exist in the default directory or path
FKLABEL()*      Return function key name
FKMAX()*        Return number of function keys as a constant
FLOCK()         Lock an open and shared database file
FOPEN()         Open a binary file
FOUND()         Determine if the previous search operation succeeded
FRENAME()       Change the name of a file
FSEEK()         Set a binary file pointer to a new position
FWRITE()        Write to an open binary file
GETACTIVE()     Return the currently active Get object
GETAPPLYKEY()   Apply a key to a Get object from within a reader
GETDOSETKEY()   Process SET KEY during GET editing
GETENV()        Retrieve the contents of a DOS environment variable
GETPOSTVALID()  Postvalidate the current Get object
GETPREVALID()   Prevalidate a Get object
HARDCR()        Replace all soft carriage returns with hard carriage returns
I2BIN()         Convert a CA-Clipper numeric to a 16-bit binary integer
IF()            Return the result of an expression based on a condition
IIF()           Return the result of an expression based on a condition
INDEXEXT()      Return index extension defined by the current database driver
INDEXKEY()      Return the key expression of a specified index
INDEXORD()      Return the order position of the controlling index
INKEY()         Extract a character from the keyboard buffer or a mouse event
INT()           Convert a numeric value to an integer
ISALPHA()       Determine if the leftmost character in a string is alphabetic
ISCOLOR()       Determine if the current computer has color capability
ISDIGIT()       Determine if the leftmost character in a string is a digit
ISLOWER()       Determine if the leftmost character is a lowercase letter
ISPRINTER()     Determine whether LPT1 is ready
ISUPPER()       Determine if the leftmost character in a string is uppercase
L2BIN()         Convert a CA-Clipper numeric value to a 32-bit binary integer
LASTKEY()       Return INKEY() value of last key extracted from the keyboard
LASTREC()       Determine the number of records in the current .dbf file
LEFT()          Extract substring beginning with first character in a string
LEN()           Return the length of a string or number of array elements
LOG()           Calculate the natural logarithm of a numeric value
LOWER()         Convert uppercase characters to lowercase
LTRIM()         Remove leading spaces from a character string
LUPDATE()       Return the last modification date of a database (.dbf) file
MAX()           Return the larger of two numeric or date values
MAXCOL()        Determine the maximum visible screen column
MAXROW()        Determine the maximum visible screen row
MEMOEDIT()      Display or edit character strings and memo fields
MEMOLINE()      Extract a line of text from a character string or memo field
MEMOREAD()      Return the contents of a disk file as a character string
MEMORY()        Determine the amount of available free pool memory
MEMOSETSUPER()  Set an RDD inheritance chain for the DBFMEMO database driver
MEMOTRAN()      Replace carriage return/linefeeds in character strings
MEMOWRIT()      Write a character string or memo field to a disk file
MEMVARBLOCK()   Return a set-get code block for a given memory variable
MIN()           Return the smaller of two numeric or date values
MLCOUNT()       Count the number of lines in a character string or memo field
MLCTOPOS()      Return position of a string based on line and column position
MLPOS()         Determine the position of a line in a string or memo field
MOD()*          Return the dBASE III PLUS modulus of two numbers
MONTH()         Convert a date value to the number of the month
MPOSTOLC()      Return line/ column position of a string based on a position
NETERR()        Determine if a network command has failed
NETNAME()       Return the current workstation identification
NEXTKEY()       Read the pending key in the keyboard buffer
NOSNOW()        Toggle snow suppression
ORDBAGEXT()     Return the default order bag RDD extension
ORDBAGNAME()    Return the order bag name of a specific order
ORDCOND()       Specify conditions for ordering
ORDCONDSET()    Set the condition and scope for an order
ORDCREATE()     Create an order in an order bag
ORDDESCEND()    Return and optionally change the descending flag of an order
ORDDESTROY()    Remove a specified order from an order bag
ORDFOR()        Return the FOR expression of an order
ORDISUNIQUE()   Return the status of the unique flag for a given order
ORDKEY()        Return the key expression of an order
ORDKEYCOUNT()   Return the number of keys in an order
ORDKEYDEL()     Delete a key from a custom built order
ORDKEYGOTO()    Move to a record specified by its logical record number
ORDKEYNO()      Get the logical record number of the current record
ORDKEYVAL()     Get key value of the current record from controlling order
ORDLISTCLEAR()  Clear the current order list
ORDLISTREBUI()  Rebuild all orders in the order list of the current work area
ORDNAME()       Return the name of an order in the order list
ORDNUMBER()     Return the position of an order in the current order list
ORDSCOPE()      Set or clear the boundaries for scoping key values
ORDSETFOCUS()   Set focus to an order in an order list
ORDSETRELAT()   Relate a specified work area to the current work area
ORDSKIPUNIQUE() Move record pointer to the next or previous unique key
OS()            Return the operating system name
OUTERR()        Write a list of values to the standard error device
OUTSTD()        Write a list of values to the standard output device
PCOL()          Return the current column position of the printhead
PCOUNT()        Determine the position of the last actual parameter passed
PROCLINE()      Return source line number of current or previous activation
PROCNAME()      Return name of the current or previous procedure or function
PROW()          Return the current row position of the printhead
QOUT()          Display a list of expressions to the console
RAT()           Return the position of the last occurrence of a substring
RDDLIST()       Return an array of the RDDs
RDDNAME()       Return name of RDD active in current or specified work area
RDDSETDEFAULT() Set or return the default RDD for the application
READFORMAT()    Return and optionally set code block to implement format file
READMODAL()     Activate a full-screen editing mode for a GetList
RECCOUNT()*     Determine the number of records in the current database file
RECNO()         Return the identity at the position of the record pointer
RECSIZE()       Determine the record length of a database (.dbf) file
REPLICATE()     Return a string repeated a specified number of times
RESTSCREEN()    Display a saved screen region to a specified location
RIGHT()         Return a substring beginning with the rightmost character
RLOCK()         Lock the current record in the active work area
ROUND()         Return a numeric value rounded to a specified number of digits
ROW()           Return the screen row position of the cursor
RTRIM()         Remove trailing spaces from a character string
SAVESCREEN()    Save a screen region for later display
SCROLL()        Scroll a screen region up or down, right or left
SECONDS()       Return the number of seconds elapsed since midnight
SELECT()        Determine the work area number of a specified alias
SET()           Inspect or change a system setting
SETCANCEL()     Toggle Alt+C and Ctrl+Break as program termination keys
SETCOLOR()      Return the current colors and optionally set new colors
SETCURSOR()     Set the cursor shape
SETKEY()        Assign an action block to a key
SETMODE()       Change display mode to a specified number of rows and columns
SETPOS()        Move the cursor to a new position
SETPRC()        Set PROW() and PCOL() values
SOUNDEX()       Convert a character string to "soundex" form
SPACE()         Return a string of spaces
SQRT()          Return the square root of a positive number
STR()           Convert a numeric expression to a character string
STRTRAN()       Search and replace characters within a string or memo field
STUFF()         Delete and insert characters in a string
SUBSTR()        Extract a substring from a character string
TIME()          Return the system time
TONE()          Sound a speaker tone for a specified frequency and duration
TRANSFORM()     Convert any value into a formatted character string
TRIM()          Remove trailing spaces from a character string
TYPE()          Determine the type of an expression
UPDATED()       Determine whether a GET changed during a READ
UPPER()         Convert lowercase characters to uppercase
USED()          Determine whether a database file is in USE
VAL()           Convert a character number to numeric type
VALTYPE()       Determine the data type returned by an expression
VERSION()       Returns CA-Clipper version
WORD()*         Convert CALL command numeric parameters from double to int
YEAR()          Convert a date value to the year as a numeric value```

``` ADEL()
Delete an array element
------------------------------------------------------------------------------
Syntax

Arguments

<aTarget> is the array to delete an element from.

<nPosition> is the position of the target array element to be
deleted.

Returns

ADEL() returns a reference to the target array, <aTarget>.

Description

ADEL() is an array function that deletes an element from an array.  The
contents of the specified array element is lost, and all elements from
that position to the end of the array are shifted up one element.  The
last element in the array becomes NIL.

Warning!  Clipper implements multidimensional arrays by nesting
arrays within other arrays.  If the <aTarget> array is a
multidimensional array, ADEL() can delete an entire subarray specified
by <nPosition>, causing <aTarget> to describe an array with a different
structure than the original.

Examples

.  This example creates a constant array of three elements, and
then deletes the second element.  The third element is moved up one
position, and the new third element is assigned a NIL:

LOCAL aArray
aArray := { 1, 2, 3 }      // Result: aArray is
// now { 1, 2, 3 }
ADEL(aArray, 2)            // Result: aArray is
// now { 1, 3, NIL }

Files   Library is CLIPPER.LIB.

```

` `