Difference between revisions of "AFIELDS()"

From Lianjapedia
Jump to: navigation, search
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
Function to fill a series of arrays with table structure details
+
Function to fill an array with table structure details
  
 
==Syntax==
 
==Syntax==
AFIELDS(<array1> [,<array2> [,<array3> [,<array4>]]])
 
 
 
AFIELDS(<array> [,<workarea | alias>])
 
AFIELDS(<array> [,<workarea | alias>])
  
 
==See Also==
 
==See Also==
[[AADD()]], [[AAVERAGE()]], [[ABROWSE()]], [[ACHOICE()]], [[ACOL()]], [[ACOPY()]], [[ADEL()]], [[ADESC()]], [[ADIR()]], [[AELEMENT()]], [[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()]], [[ADEL()]], [[ADESC()]], [[ADIR()]], [[AELEMENT()]], [[AFILL()]], [[AINS()]], [[ALEN()]], [[AMAX()]], [[AMIN()]], [[APPEND FROM ARRAY]], [[ARRAY()]], [[ASCAN()]], [[ASIZE()]], [[ASORT()]], [[ASTORE()]], [[ASTRING()]], [[ASUBSCRIPT()]], [[ASUM()]], [[ATABLES()]], [[COPY TO ARRAY]], [[DECLARE]], [[DIMENSION]], [[GATHER]], [[IN_ARRAY()]], [[IS_ARRAY()]], [[LOCAL]], [[PRIVATE]], [[PUBLIC]], [[RELEASE]], [[RESTORE]], [[SAVE]], [[SCATTER]]
  
 
==Description==
 
==Description==
The AFIELDS() function returns the number of fields in the table in the current workarea and loads the field names into an array, <array1>.  The field types, field lengths and field decimals can also be loaded into individual arrays.
+
The AFIELDS() function returns the number of fields in the table in the current or specified cursor/workarea and loads the information detailed in the table below into the 18 columns of the array <array>.  Each row in the array corresponds to a field in the table.  If the optional <workarea | alias> is specified, then the function will operate in the required location, otherwise it will operate in the current cursor/workarea.
 
+
 
+
{| class="wikitable"
+
!Parameters||Description
+
|-
+
|<array1>||The name of a pre-declared array in which to load the character string field name.
+
|-
+
|<array2>||The name of a pre-defined array in which to load the field data types as character strings.
+
|-
+
|<array3>||The name of a pre-defined array in which to load the field lengths as numeric values.
+
|-
+
|<array4>||The name of a pre-defined array in which to load the field decimal places as numeric values.  If the field is not a numeric data type or has no decimal places, then zero is returned.
+
|-
+
|}
+
 
+
 
+
The SET FIELDS command can be used to restrict the active fields and therefore determine which fields are copied into the array.
+
  
With SET COMPATIBLE set to FoxPro, Foxbase or VFP, the AFIELDS() function syntax conforms to Visual FoxPro behavior.  The information detailed in the table below is loaded into the 18 columns of the single array <array>.  Each row in the array corresponds to a field in the table.  If the optional <workarea | alias> is specified, then the function will operate in the required location, otherwise it will operate in the current workarea.
+
The SET FIELDS command can be used to restrict the active fields.
  
  
{| class="wikitable"
+
{| class="wikitable" width="100%"
!Column||Information||Data Type
+
!width="10%"|Column||Information||width="30%"|Data Type
 
|-
 
|-
 
|1||Field name||Character
 
|1||Field name||Character
 
|-
 
|-
|2||Field type:
+
|valign="top"|2||Field type:
  
 
C = Character
 
C = Character
Line 66: Line 47:
 
V = Varchar and Varchar (Binary)
 
V = Varchar and Varchar (Binary)
  
W = Blob||Character
+
W = Blob
 +
|valign="top"|Character
 
|-
 
|-
 
|3||Field width||Numeric
 
|3||Field width||Numeric
Line 105: Line 87:
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
use patrons
+
open database southwind
declare tab1(12),tab2(12),tab3(12),tab4(12)
+
use customers
fields = afields(tab1,tab2,tab3,tab4)
+
? afields(myarr)
 +
display memory
 
</code>
 
</code>
  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
[[Category:Array Processing]]
 
 
[[Category:Array Processing Functions]]
 
[[Category:Array Processing Functions]]

Latest revision as of 07:54, 30 May 2013

Purpose

Function to fill an array with table structure details

Syntax

AFIELDS(<array> [,<workarea | alias>])

See Also

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

Description

The AFIELDS() function returns the number of fields in the table in the current or specified cursor/workarea and loads the information detailed in the table below into the 18 columns of the array <array>. Each row in the array corresponds to a field in the table. If the optional <workarea | alias> is specified, then the function will operate in the required location, otherwise it will operate in the current cursor/workarea.

The SET FIELDS command can be used to restrict the active fields.


Column Information Data Type
1 Field name Character
2 Field type:

C = Character

Y = Currency

D = Date

T = DateTime

B = Double

F = Float

G = General

I = Integer

L = Logical

M = Memo

N = Numeric

Q = Varbinary

V = Varchar and Varchar (Binary)

W = Blob

Character
3 Field width Numeric
4 Decimal places Numeric
5 Null values allowed Logical
6 Code page translation not allowed Logical
7 Field validation expression Character
8 Field validation text Character
9 Field default value Character
10 Table validation expression Character
11 Table validation text Character
12 Long table name Character
13 Insert trigger expression Character
14 Update trigger expression Character
15 Delete trigger expression Character
16 Table comment Character
17 NextValue for autoincrementing Numeric
18 Step for autoincrementing Numeric


Example

open database southwind
use customers
? afields(myarr)
display memory