This article is reprinted from the January 1991 edition of
TechNotes/dBASE IV. Due to the limitations of this media, certain
graphic elements such as screen shots, illustrations and some tables
have been omitted. Where possible, reference to such items has been
deleted. As a result, continuity may be compromised.
TechNotes is a monthly publication from the Ashton-Tate Software
Support Center. For subscription information, call 800-545-9364.
For some, life is simple enough to justify one subdirectory. Either
there's not much to clutter their lives or they simply aren't inspired
enough to organize the myriad of files that exist on their hard
There are those that have separate subdirectories that contain
specific applications with corresponding data files. It is for this
frustrated bunch that we focus the topic of this article.
Here is a program that examines your dBASE directory, gathers all the
subdirectory names into a popup. By selecting a subdirectory, the
program changes the default to that specific subdirectory; an
excellent front-end utility to build into your start up application.
With the new SET DIRECTORY command, the need for .BAT files invoked
before starting dBASE IV becomes obsolete.
Before adding this program to your application, you must first make a
simple database structure that will be utilized by the program. Make
a database called "CD" containing two fields:
NAME - character field, eight(8) wide
EXT - character field, ten(10) wide
Put CD.PRG and CD.DBF in the directory where the dBASE IV program
files reside. If you wish for this program to activate each time you
start dBASE IV, put the following statement in your CONFIG.DB file.
COMMAND = DO CD
This program works on the assumption that directories you wish to
switch to are subdirectories of the directory you are currently in
from which you are running CD.PRG.
* Change Directory Program
* This program looks for any subdirectories of the current
* directory and displays them in a popup menu. When selected,
* the default directory is changed.
* Other necessary files include:
* Fields: NAME - Character, eight (8) wide
* EXT - Character, ten (10) wide
* Instructions for use:
* - Put CD.PRG and CD.DBF in the DBASE directory (such as C:\DBASE)
* - Call dBASE from the DBASE directory
*Ä Save initial settings
s_talk = SET("TALK")
SET TALK OFF
s_safety = SET("SAFETY")
s_deleted = SET("DELETED")
s_status = SET("STATUS")
SET SAFETY OFF
SET DELETED ON
SET STATUS OFF
@ 10,25 say 'Reading sub-directories . . . '
*Ä Redirect the directory listing of all files with no extensions
* to the text file CD.TXT
!DIR *. > cd.txt
USE CD && Make this database (see
APPEND FROM cd.txt TYPE SDF && Append sub-directory names into
*Ä Delete records containing filenames or parent directories (.)
DELETE FOR RIGHT(EXT,5) <> "
COUNT TO max && Store number of directories
IF max > 17
@ 10,25 CLEAR TO 10,60
*Ä Make sure that there is at least one sub-directory
IF max > 0
SET DIRECTORY TO
DEFINE POPUP choose FROM 2,35 TO 3+max,45;
PROMPT FIELD name;
MESSAGE 'Choose a data directory. '+ ;
'Press Esc for current directory '+SET("DIRECTORY")
ON SELE POPUP choose DO cd_proc
@ 1,29 SAY ' Dbase Data Directories ' COLOR B/W
ACTIVATE POPUP choose
USE && close all databases
*Ä If there are no sub-directories then display this message:
@ 10,25 SAY 'No sub-directories found.'
@ 11,25 SAY 'Press any key to continue . . .'
*Ä Restore initial settings
SET SAFETY &s_safety
SET TALK &s_talk
SET DELETED &s_deleted
SET STATUS &s_status
ASSIST && if you want to go into the
* This procedure changes directory to the one
* chosen in the popup menu "CHOOSE"
SET DIRECTORY TO &dr
* EOF: CD.PRG