Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : TN9101.ZIP
Filename : DIRSWAP.TXT

 
Output of file : DIRSWAP.TXT contained in archive : TN9101.ZIP

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.

Directory Swapping
Robert Estrella

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
drives.

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.

CD.PRG
* 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:
* CD.DBF
* 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

CLEAR

@ 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
above)
ZAP
APPEND FROM cd.txt TYPE SDF && Append sub-directory names into
CD.DBF

*Ä Delete records containing filenames or parent directories (.)
DELETE FOR RIGHT(EXT,5) <> "" .OR. LEFT(NAME,1)='.'

COUNT TO max && Store number of directories
to max
IF max > 17
max=17
ENDIF

@ 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
ELSE
*Ä 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 . . .'
READ
ENDIF

*Ä Restore initial settings
SET SAFETY &s_safety
SET TALK &s_talk
SET DELETED &s_deleted
SET STATUS &s_status
CLEAR
ASSIST && if you want to go into the
Control Center

PROCEDURE cd_proc
* This procedure changes directory to the one
* chosen in the popup menu "CHOOSE"
dr=PROMPT()
SET DIRECTORY TO &dr
DEACTIVATE POPUP
RETURN

* EOF: CD.PRG



  3 Responses to “Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : TN9101.ZIP
Filename : DIRSWAP.TXT

  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/