Difference between revisions of "ADEL()"

From Lianjapedia
Jump to: navigation, search
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Function to delete an element from an array
 
Function to delete an element from an array
 
  
 
==Syntax==
 
==Syntax==
 
ADEL(<array>,<expN>[,2])
 
ADEL(<array>,<expN>[,2])
 
  
 
==See Also==
 
==See Also==
[[AADD()]], [[AAVERAGE()]], [[ABROWSE()]], [[ACHOICE()]], [[ACOL()]], [[ACOPY()]], [[ADESC()]], [[ADIR()]], [[AELEMENT()]], [[AFIELDS()]], [[AFILL()]], [[AINS()]], [[ALEN()]], [[AMAX()]], [[AMIN()]], [[APPEND FROM ARRAY]], [[AROW()]], [[ARRAY()]], [[ASCAN()]], [[ASIZE()]], [[ASORT()]], [[ASTORE()]], [[ASTRING()]], [[ASUBSCRIPT()]], [[ASUM()]], [[COPY TO ARRAY]], [[DECLARE]], [[DIMENSION]], [[GATHER]], [[IN_ARRAY()]], [[IS_ARRAY()]], [[LOCAL]], [[PRIVATE]], [[PUBLIC]], [[RELEASE]], [[RESTORE]], [[SAVE]], [[SCATTER]]
+
[[AADD()]], [[AAVERAGE()]], [[ACOPY()]], [[ADESC()]], [[ADIR()]], [[AELEMENT()]], [[AFIELDS()]], [[AFILL()]], [[AINS()]], [[ALEN()]], [[AMAX()]], [[AMIN()]], [[APPEND FROM ARRAY]], [[ARRAY()]], [[ASCAN()]], [[ASIZE()]], [[ASORT()]], [[ASTORE()]], [[ASTRING()]], [[ASUBSCRIPT()]], [[ASUM()]], [[COPY TO ARRAY]], [[DECLARE]], [[DIMENSION]], [[GATHER]], [[IN_ARRAY()]], [[IS_ARRAY()]], [[LOCAL]], [[PRIVATE]], [[PUBLIC]], [[RELEASE]], [[RESTORE]], [[SAVE]], [[SCATTER]]
 
+
  
 
==Description==
 
==Description==
Line 15: Line 12:
  
 
For two-dimensional arrays, the <expN> refers to an entire row of elements, rather than an individual element.  If the '2' parameter is included, the <expN> refers to an entire column of elements.
 
For two-dimensional arrays, the <expN> refers to an entire row of elements, rather than an individual element.  If the '2' parameter is included, the <expN> refers to an entire column of elements.
 
  
 
==Example==
 
==Example==
Line 25: Line 21:
 
endif
 
endif
  
//Another Example
+
// Two-dimensional array Examples:
set compatible to foxpro
+
dimension array1(3,3)
+
array1(1,1) = "one"
+
array1(1,2) = 1
+
array1(1,3) = ctod("01/01/2001")
+
array1(2,1) = "two"
+
array1(2,2) = 2
+
array1(2,3) = ctod("02/02/2002")
+
array1(3,1) = "three"
+
array1(3,2) = 3
+
array1(3,3) = ctod("03/03/2003")
+
//Delete row 2
+
adel(array1,2)
+
//Delete column 1
+
adel(array1,1,2)
+
</code>
+
  
 +
// Row
 +
open database southwind
 +
use shippers
 +
copy to array arr1
 +
? arr1
 +
// Delete row 2
 +
adel(arr1,2)
 +
? arr1
 +
close data
 +
 +
// Results:
 +
Array (refcnt=1)
 +
(
 +
    [1,1] = 1
 +
    [1,2] = Speedy Express                         
 +
    [1,3] = (503) 555-9831         
 +
    [2,1] = 2
 +
    [2,2] = United Package                         
 +
    [2,3] = (503) 555-3199         
 +
    [3,1] = 3
 +
    [3,2] = Federal Shipping                       
 +
    [3,3] = (503) 555-9931         
 +
)
 +
 +
Array (refcnt=1)
 +
(
 +
    [1,1] = 1
 +
    [1,2] = Speedy Express                         
 +
    [1,3] = (503) 555-9831         
 +
    [2,1] = 3
 +
    [2,2] = Federal Shipping                       
 +
    [2,3] = (503) 555-9931         
 +
    [3,1] = False
 +
    [3,2] = False
 +
    [3,3] = False
 +
)
 +
 +
// Column
 +
open database southwind
 +
use shippers
 +
copy to array arr1
 +
? arr1
 +
// Delete column 2
 +
adel(arr1,2,2)
 +
? arr1
 +
close data
 +
 +
// Results:
 +
Array (refcnt=1)
 +
(
 +
    [1,1] = 1
 +
    [1,2] = Speedy Express                         
 +
    [1,3] = (503) 555-9831         
 +
    [2,1] = 2
 +
    [2,2] = United Package                         
 +
    [2,3] = (503) 555-3199         
 +
    [3,1] = 3
 +
    [3,2] = Federal Shipping                       
 +
    [3,3] = (503) 555-9931         
 +
)
 +
 +
Array (refcnt=1)
 +
(
 +
    [1,1] = 1
 +
    [1,2] = (503) 555-9831         
 +
    [1,3] = False
 +
    [2,1] = 2
 +
    [2,2] = (503) 555-3199         
 +
    [2,3] = False
 +
    [3,1] = 3
 +
    [3,2] = (503) 555-9931         
 +
    [3,3] = False
 +
)
 +
 +
</code>
  
==Products==
 
Recital Server, Recital
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
[[Category:Array Processing]]
 
 
[[Category:Array Processing Functions]]
 
[[Category:Array Processing Functions]]

Latest revision as of 06:56, 25 February 2015

Purpose

Function to delete an element from an array

Syntax

ADEL(<array>,<expN>[,2])

See Also

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

Description

The ADEL() function deletes the element at position <expN> of the specified <array>. All elements higher than the deleted element will be shifted down and the last element in the <array> will become .F.. The total number of elements in the <array> will remain the same.

For two-dimensional arrays, the <expN> refers to an entire row of elements, rather than an individual element. If the '2' parameter is included, the <expN> refers to an entire column of elements.

Example

element_no = ascan(flist,"New information")
// If element exists
if m.element_no > 0
    adel(flist,m.element_no)
endif
 
// Two-dimensional array Examples:
 
// Row
open database southwind
use shippers
copy to array arr1
? arr1
// Delete row 2
adel(arr1,2)
? arr1
close data
 
// Results:
Array (refcnt=1)
(
    [1,1] = 1
    [1,2] = Speedy Express                          
    [1,3] = (503) 555-9831          
    [2,1] = 2
    [2,2] = United Package                          
    [2,3] = (503) 555-3199          
    [3,1] = 3
    [3,2] = Federal Shipping                        
    [3,3] = (503) 555-9931          
)
 
Array (refcnt=1)
(
    [1,1] = 1
    [1,2] = Speedy Express                          
    [1,3] = (503) 555-9831          
    [2,1] = 3
    [2,2] = Federal Shipping                        
    [2,3] = (503) 555-9931          
    [3,1] = False
    [3,2] = False
    [3,3] = False
)
 
// Column
open database southwind
use shippers
copy to array arr1
? arr1
// Delete column 2
adel(arr1,2,2)
? arr1
close data
 
// Results:
Array (refcnt=1)
(
    [1,1] = 1
    [1,2] = Speedy Express                          
    [1,3] = (503) 555-9831          
    [2,1] = 2
    [2,2] = United Package                          
    [2,3] = (503) 555-3199          
    [3,1] = 3
    [3,2] = Federal Shipping                        
    [3,3] = (503) 555-9931          
)
 
Array (refcnt=1)
(
    [1,1] = 1
    [1,2] = (503) 555-9831          
    [1,3] = False
    [2,1] = 2
    [2,2] = (503) 555-3199          
    [2,3] = False
    [3,1] = 3
    [3,2] = (503) 555-9931          
    [3,3] = False
)