Category : Files from Magazines
Archive   : DBMS0690.ZIP
Filename : HEAD2

 
Output of file : HEAD2 contained in archive : DBMS0690.ZIP

LISTING 2
---------

1 : *
2 : * ADIRDEMO.PRG
3 : *
4 : * Demonstrate the use CLIPPER function ADIR()
5 : * using all six parameters to include HIDDEN files
6 : * and sub-directories.
7 : *
8 : * Procedure to sort directory arrays added by Warren Hart
9 : *
10 : * Placed in the public domain NSA (No Strings Attached)
11 : *
12 :
13 : CLEAR
14 :
15 : ambig = SPACE(25)
16 : @ 12,12 SAY "Enter ambiguous file name -> "
GET ambig PICTURE "@!"
17 : READ
18 :
19 : * Dummy parameter used as a place-holder
20 : dummy = ""
21 :
22 : * Initial array for attribute. Used to get a file count
23 : DECLARE f_attrib[1]
24 :
25 : * How many files match the ambiguous skeleton?
26 : f_count = ADIR(ambig, dummy, dummy, dummy, dummy, f_attrib)
27 :
28 : * Create three arrays to hold file name, size and attribute
29 : DECLARE f_name[f_count], f_size[f_count], f_attrib[f_count]
30 :
31 : * Scan directory again and populate declared arrays
32 : f_found = ADIR(ambig, f_name, f_size, dummy, dummy, f_attrib)
33 :
34 : * Sort the listing by file_name + file_extent
35 : DO sort_dir WITH f_name
36 :
37 : * List what we have discovered
38 : FOR x = 1 TO f_found
39 : ptr = VAL(SUBSTR(f_name[x],15))
40 : ? STR(x,5) + SPACE(3) && Line number
41 : ?? SUBSTR(f_name[x] + SPACE(20),1,15)
&& File name
42 : size = LEN(ALLTRIM(STR(f_size[ptr])))
&& Flush file size
to the right
43 : ?? SPACE(8 - size) + ALLTRIM(STR(f_size[ptr]))

44 : ?? SPACE(4) + f_attrib[ptr] && Show attribute
45 : NEXT x
46 :
47 : * Show summary message
48 : ?
49 : ? ALLTRIM(STR(f_found)) + " Total files matching -> " + ambig
50 : ?
51 :
52 : RETURN
53 :
54 :
55 : * First format the array elements and then append array
56 : * pointer string to the end of each element. Finally,
57 : * sort the formatted array using ASORT() function.
58 : ******************
59 : PROCEDURE sort_dir
60 : PARAMETER array
61 :
62 : FOR x = 1 TO LEN(array)
63 : array[x] = FORMAT(array[x], (f_attrib[x] = "D")) + STR(x,6)
64 : NEXT x
65 :
66 : ASORT(array)
67 :
68 : RETURN
69 :
70 :
71 : * Format the file.ext to "file ext".
72 : * Append "" for subdirectories.
73 : ***************
74 : FUNCTION format
75 : PARAMETER element, subdir
76 :
77 : IF ! subdir
78 : IF "." $ element
79 : f = SUBSTR(SUBSTR(element, 1, AT(".",element) -1) + ;
SPACE(8) ,1 ,8)
80 : e = " "+SUBSTR(SUBSTR(element, AT(".",element) +1) + ;
SPACE(3) ,1 ,3) + " "
81 : ELSE
82 : f = SUBSTR(element + SPACE(8), 1, 8)
83 : e = " "
84 : ENDIF
85 : ELSE
86 : f = SUBSTR(element + SPACE(8), 1, 8)
87 : e = ""
88 : ENDIF
89 :
90 : RETURN ( f + " " + e )
91 :
92 : ** END OF ADIRDEMO.PRG



  3 Responses to “Category : Files from Magazines
Archive   : DBMS0690.ZIP
Filename : HEAD2

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/