Difference between revisions of "ADIR()"

From Lianjapedia
Jump to: navigation, search
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==
Line 9: Line 9:
  
 
==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
 
!Character||Description
 
|-
 
|-
 
|?||Matches any one character.
 
|?||Matches any one character.
|-
 
|%||Matches any one character.
 
 
|-
 
|-
 
|*||Matches zero or more characters.
 
|*||Matches zero or more characters.
Line 22: Line 20:
 
|}
 
|}
  
The ADIR() function may also be used to load directory information into arrays.
+
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:
  
{| class="wikitable"
+
{| class="wikitable" width = 100%
!Parameters||Description
+
!Column||Contents||Type
 
|-
 
|-
|<skeleton>||The character string specifying the file skeleton.
+
|1||Name||Character
 
|-
 
|-
|<array1>||The name of a pre-declared array in which to load the character string file names that match the specified skeleton.
+
|2||Size||Numeric
 
|-
 
|-
|<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.
+
|3||Last modification date||Date
 
|-
 
|-
|<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.
+
|4||Last modification time||Character
 
|-
 
|-
|<array4>||The name of a pre-defined array in which to load the character type creation time of the files matching the specified skeleton.
+
|5||Attributes||Character
 
|-
 
|-
|<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 attributes filter in <expC> can be any of the following:
 +
 
 +
{| class="wikitable" width = 100%
 +
!Letter||Attribute
 +
|-
 +
|A||Archive (Read/Write)
 +
|-
 +
|H||Hidden
 +
|-
 +
|R||Read only
 +
|-
 +
|S||System
 +
|-
 +
|D||Directory
 
|-
 
|-
 
|}
 
|}
 +
 +
The flags <expN> parameter is parsed, but ignored.  File names are always returned in full and in upper case.
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
declare files[adir("*.dbf")]
+
nTables = adir(aTables, "*.dbf")
nTables = adir("*.dbf",files)
+
 
</code>
 
</code>
  

Revision as of 06:49, 22 January 2013

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(), AFILL(), AINS(), ALEN(), AMAX(), AMIN(), APPEND FROM ARRAY, 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

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 Contents Type
1 Name Character
2 Size Numeric
3 Last modification date Date
4 Last modification time Character
5 Attributes Character

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 parsed, but ignored. File names are always returned in full and in upper case.

Example

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