BBS: Inland Empire Archive
Date: 05-29-92 (01:36)             Number: 134
From: MARK BUTLER                  Refer#: NONE
  To: CHRIS WAGNER                  Recvd: NO  
Subj: Dirs                           Conf: (2) Quik_Bas
 On 05-25-92 Chris Wagner wrote to Dave Abraham...

 CW>  DA> Ok, here's the deal.  I have a function that works in
 CW>  DA> QB45 just fine.  It gets the directory and stores it
 CW>  DA> into arrays.  The problem with the routine is, it does
 CW>  DA> NOT work in PDS 7.1.  I have no idea why and I don't
 CW>  DA> know enough about it to convert it.  Does anyone have
 CW>  DA> a routine that works?  Thanx...
 CW>  Look up SADD in your PDS manual (Page 305).  I think you will
 CW>  need to use SADD in place of VARPTR due to the way that BASIC 7.1x
 CW>  uses FAR strings.

 Actually there's an easier way around it than trying to doctor QB45
 directory rotuines that will no longer work. Most of the following
 snippet was clipped directly from QBX's online help as a demo of the
 DIR$ function. The way I'm using it here is to stuff every filename
 returned in "filespec$" into the array FIL$()....

 --------------------------8< CUT HERE 8<-----------------------------
 DECLARE FUNCTION GetFileCount& (filespec$)
 DIM FIL$(1 TO 2)

    filespec$ = "*.*"
    Count = GetFileCount(filespec$)
    PRINT Count; "files match the file specification."
    REDIM FIL$(1 TO Count)
    FIL$(1) = DIR$("*.*")
    FOR i% = 2 TO Count
        FIL$(i%) = DIR$
        PRINT LCASE$(FIL$(i%))  '<---- display the contents of the
    NEXT                        '      file array FIL$()

 REM $STATIC  '*** this function clipped from the QBX online help ***
 FUNCTION GetFileCount& (filespec$)
 'This function evaluates a file specification and returns the
 'number of files that match the specification.  Wild card characters
 '("*" and "?") are permitted. Drive and directory path specifications
 'may also be included in filespec$.
 DIM FileCount AS LONG
    IF LEN(DIR$(filespec$)) = 0 THEN     'Ensure filespec is valid.
        FileCount& = 0                   'It's not.
        FileCount = 1                    'It is, so count files.
        DO WHILE LEN(DIR$) > 0
            FileCount& = FileCount& + 1
    END IF
    GetFileCount = FileCount&

 --------------------------8< CUT HERE 8<-----------------------------

 Hope this is of some assistance.

 ---------> MHB :-)

... OFFLINE 1.37 * The future isn't what it used to be
--- DB B1069/001271
 * Origin: * Bare Bones BBS * (1:105/360)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET