Difference between revisions of "ADIR()"

From Lianjapedia
Jump to: navigation, search
 
(See Also)
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
Function to return number of files matching a file pattern
+
Function to return number of files and/or directories matching a file pattern and load file information into an array
 
+
  
 
==Syntax==
 
==Syntax==
ADIR(<skeleton> [,<array1> [,<array2> [,<array3> [,<array4> [,<array5>]]]]])
+
ADIR(<array> [, <skeleton> [, <expC> [, <expN>]]])
 
+
  
 
==See Also==
 
==See Also==
[[AADD()]], [[AAVERAGE()]], [[ABROWSE()]], [[ACHOICE()]], [[ACOL()]], [[ACOPY()]], [[ADEL()]], [[ADESC()]], [[AELEMENT()]], [[AFIELDS()]], [[AFILL()]], [[AINS()]], [[ALEN()]], [[AMAX()]], [[AMIN()]], [[APPEND FROM ARRAY]], [[AROW()]], [[ARRAY()]], [[ASCAN()]], [[ASIZE()]], [[ASORT()]], [[ASTORE()]], [[ASTRING()]], [[ASUBSCRIPT()]], [[ASUM()]], [[COPY TO ARRAY]], [[DECLARE]], [[DIMENSION]], [[FDATE()]], [[FILE()]], [[GATHER]], [[IN_ARRAY()]], [[IS_ARRAY()]], [[LOCAL]], [[PRIVATE]], [[PUBLIC]], [[RELEASE]], [[RESTORE]], [[SAVE]], [[SCATTER]]
+
[[AADD()]], [[AAVERAGE()]], [[ACOPY()]], [[ADEL()]], [[ADESC()]], [[AELEMENT()]], [[AFIELDS()]], [[AFILES()]], [[AFILL()]], [[AINS()]], [[ALEN()]], [[AMAX()]], [[AMIN()]], [[APPEND FROM ARRAY]], [[ARRAY()]], [[ASCAN()]], [[ASIZE()]], [[ASORT()]], [[ASTORE()]], [[ASTRING()]], [[ASUBSCRIPT()]], [[ASUM()]], [[COPY TO ARRAY]], [[DECLARE]], [[DIMENSION]], [[DIR]], [[FDATE()]], [[FILE()]], [[GATHER]], [[IN_ARRAY()]], [[IS_ARRAY()]], [[LOCAL]], [[PRIVATE]], [[PUBLIC]], [[RELEASE]], [[RESTORE]], [[SAVE]], [[SCATTER]], [[SYSFILES]]
 
+
  
 
==Description==
 
==Description==
The ADIR() function returns the number of files which match the specified file skeleton.  The following 'wild card' characters can be used:
+
The ADIR() function returns the number of files and/or directories which match the specified file skeleton and loads file information into the array <array>.  The following 'wild card' characters can be used in the <skeleton>:
 
+
  
{| class="wikitable"
+
{| class="wikitable" width="100%"
!Character||Description
+
!width="25%"|Character||width="75%"|Description
 
|-
 
|-
 
|?||Matches any one character.
 
|?||Matches any one character.
|-
 
|%||Matches any one character.
 
 
|-
 
|-
 
|*||Matches zero or more characters.
 
|*||Matches zero or more characters.
Line 26: Line 20:
 
|}
 
|}
  
 +
If ADIR() returns a value greater than 0, the <array> will be created if it does not exist and resized if previously in existence.  The ADIR() function will load the following information about the files/directories into the array:
  
The ADIR() function may also be used to load directory information into arrays.
+
{| class="wikitable" width="100%"
 +
!width="25%"|Column||width="25%"|Type||width="50%"|Contents
 +
|-
 +
|1||Character||Name
 +
|-
 +
|2||Numeric||Size
 +
|-
 +
|3||Date||Last modification date
 +
|-
 +
|4||Character||Last modification time
 +
|-
 +
|5||Character||Attributes
 +
|-
 +
|}
  
 +
The attributes filter in <expC> can be any of the following:
  
{| class="wikitable"
+
{| class="wikitable" width="100%"
!Parameters||Description
+
!width="25%"|Letter||width="75%"|Attribute
 
|-
 
|-
|<skeleton>||The character string specifying the file skeleton.
+
|A||Archive (Read/Write)
 
|-
 
|-
|<array1>||The name of a pre-declared array in which to load the character string file names that match the specified skeleton.
+
|H||Hidden
 
|-
 
|-
|<array2>||The name of a pre-defined array in which to load the numeric type file size in bytes of the files that match the specified skeleton.
+
|R||Read only
 
|-
 
|-
|<array3>||The name of a pre-defined array in which to load the date type creation date of the files that match the specified skeleton.
+
|S||System
 
|-
 
|-
|<array4>||The name of a pre-defined array in which to load the character type creation time of the files matching the specified skeleton.
+
|D||Directory
|-
+
|<array5>||The name of a pre-defined array.  This option has been added for compatibility purposes only.  An element containing the character string "A" will be loaded for each file that matches the specified skeleton.
+
 
|-
 
|-
 
|}
 
|}
  
 +
The flags <expN> parameter is determines the case of the file names returned.  Note: on Linux/Mac this is parsed, but ignored.  The file names are always returned in their original case.
  
If the compatibility setting is set to FoxPro, SET COMPATIBLE TO FOXPRO, ADIR() is fully compatible with FoxPro syntax and behavior.
+
{| class="wikitable" width="100%"
 
+
!width="25%"|Flag||width="75%"|Case
 +
|-
 +
|||Upper
 +
|-
 +
|0||Upper
 +
|-
 +
|1||Original
 +
|-
 +
|}
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
declare files[adir("*.dbf")]
+
nTables = adir(aTables, "*.dbf")
nTables = adir("*.dbf",files)
+
 
</code>
 
</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 13:02, 2 March 2022

Purpose

Function to return number of files and/or directories matching a file pattern and load file information into an array

Syntax

ADIR(<array> [, <skeleton> [, <expC> [, <expN>]]])

See Also

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

Description

The ADIR() function returns the number of files and/or directories which match the specified file skeleton and loads file information into the array <array>. The following 'wild card' characters can be used in the <skeleton>:

Character Description
? Matches any one character.
* Matches zero or more characters.

If ADIR() returns a value greater than 0, the <array> will be created if it does not exist and resized if previously in existence. The ADIR() function will load the following information about the files/directories into the array:

Column Type Contents
1 Character Name
2 Numeric Size
3 Date Last modification date
4 Character Last modification time
5 Character Attributes

The attributes filter in <expC> can be any of the following:

Letter Attribute
A Archive (Read/Write)
H Hidden
R Read only
S System
D Directory

The flags <expN> parameter is determines the case of the file names returned. Note: on Linux/Mac this is parsed, but ignored. The file names are always returned in their original case.

Flag Case
Upper
0 Upper
1 Original

Example

nTables = adir(aTables, "*.dbf")