|Powered by QM on a Rpi server|
This article was originally published as a Tip of the Week.
The DIR() function allows an application to process an operating system directory.
The syntax of this function is
LIST = DIR(PATHNAME)where PATHNAME is the operating system pathname of the directory to be processed.
The returned value from this function, stored in LIST in the above example, is a dynamic array in which there is a field for each item in the directory. The values in each field are
|1||The file or directory name of the item described by this field.|
|2||The item type; D for a directory, F for a file.|
|3||Permissions or attributes.
Unix/Linux: File permissions as a decimal value.
Windows: File attribute flags:
|4||Date/time modified as an epoch value (release 2.12-7 onwards).|
s = dir(".") n = dcount(s, @fm) for i = 1 to n display s<i,2> : ' ' : oconv(s<i,4>, 'EDMYTSL[,A3]') : ' ' : s<i,1> next iUse of this program might produce output as below.
D 11 Nov 2011 13:57:21 $COMO D 24 Oct 2011 14:02:00 $HOLD D 21 Jun 2010 20:40:15 $HOLD.DIC D 24 Oct 2011 14:02:00 $SVLISTS F 18 Oct 2011 14:42:29 AUDIT.LOG F 23 Nov 2011 10:58:23 errlog