TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ALL
from: TECH@SOFTBYTELABS.COM
date: 1998-04-05 15:48:00
subject: Re: directiory

From: Tech@SoftByteLabs.com
Subject: Re: directiory
 
On Sun, 05 Apr 1998 14:43:26 GMT, paxton@zetnet.co.uk (Tony Greenwood)
wrote:
 
>Hey! Tech@SoftByteLabs.com wasn't it Sun, 05 Apr 1998 13:52:32 GMT
>that you wrote:
>
>
>>>Done now.. thanks for the speedy response :)
>>>
>>
>>You're welcome.  Another thing you might want to know
>>if you don't already, is use CHDRIVE to change drive as
>>the CHDIR will not change to that drive.
>
>hmm hadn't checked that..
>
>I let the user enter a directory in a cfg file.. when they run my
>program it reads the config and goes to that directory, I am reading
>in the line that says what directory...if this is a different drive to
>the current one, does that mean it wont work? lets say I am in C:\TEMP
>and the cfg file says work directory is D:\WORK
>
>Will I have a problem with chdir?
>
>Simple enough to get around I suppose.. d$=left$(blah blah, if d$
>current drive then....
>
 
The way CHDIR works is it only changes the default directory
on the specific drive, or current drive.  But it will not change
the default drive to that specified in CHDIR.  For example,
The user enter "d:\temp" into d$ and you do a CHDIR d$
The D: drive's default directory will be \TEMP but the current
default drive is still C:  So if you do OPEN "anyfile.txt" it won't
work because the drive isn't specified.  But if you do
OPEN "D:anyfile.txt" without any \ then it'll work because
the default drive on D: is \temp.  I personally never use
those commands as the default directory or drive may change
for whatever reasons, especially in multi-tasking code.  I rather
use a variable like p$ containing the full path including drive
even if you have to concatenate them to create it.
 
Say the user has a choice to select a drive, save that in v$
Then he has to select a directory, save it d$ then if a file name
is also required, save it in f$ then concatenate all of them...
 
if v$ = "" then v$ = CURDRIVE
v$ = left(v$, 1) + ":"
 
The above will make sure that we save only the drive, no path
and if no drive is specified, use the default. We just get the
first letter to make sure we filter things like d; or d\ and add
the : oursself.
 
if d$="" then d$ = CURDIR$(v$)
if left(d$, 1)  "\" then d$ = "\" + d$
 
The above check to see if the directory entered has a root.
If it does, leave it alone, or else, add it to prevent making
the full path relative to the default directory.  If the user
did not enter a path, use the default on the drive specified.
 
Last, concatenate all of them into one variable p$...
p$ = v$ + d$ + f$
 
v$ will always be 2 characters like c:
d$ will always start with a \ like \temp
f$ must not be blank if file name is required.
 
You can then use p$ in anyway you like regardless of the
current drive or directory...
 
if dir$(p$) = "" then print "File don't exist."
....
open p$ for input as #1
....
kill p$
....
chdrive p$
chdir p$
 
etc etc etc
 
Michael
 
*** QwkNews (tm) v2.1
 * [TN71] Toast House Import
--- GEcho 1.20/Pro
---------------
* Origin: Toast House Remote (1:100/561)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.