Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allow User to Select Drive for File Copy

Status
Not open for further replies.

bkruger

IS-IT--Management
Oct 14, 2001
4
US
How do I pass the drive letter a user has selected for a File Copy to the program?
 
What version? It's better to have two heads to solve a problem from different angles than to have tunnel vision to a dead end.
 
Whoops, kind of an important piece of info to neglect... dBase IV
 
If the user types it in you can simply conconate the strings together.

Version 3+ example:

clear
@ 2,2 say "enter a drive Letter: " get DriveLetter
Path= &Driveletter + ":" + Path
use Path index anything
return

please note that the above is an example, I haven't actually tested it but it should work (even though this is for version 3 plus). It's better to have two heads to solve a problem from different angles than to have tunnel vision to a dead end.
 
Miggy, thanks but I've tried that. The problem is the COPY FILE command doesn't recognize 'Path'. It thinks 'Path' is the TO Filename. Here is how I tested this at the dot prompt.

DriveLetter="F"
Path=DriveLetter+":"
COPY FILE DATABASE.DBF TO PATH

What happens is the file DATABASE.DBF gets copied as PATH instead of being copied to the F: drive.
What I need to have happen is to have the F: appended onto the front of the DATABASE.DBF file so that DATABASE.DBF gets copied to the F: drive.

Regards, bkruger
 
OH NOOOO!!! What have you done?!?! You've ruined my (almost) perfect code!! <crying sounds>

Just kidding, I had purposely given you the answer; however, I placed it in the wrong spot hoping that you would catch it and jog your memory. I guess it [the answer] was a speeding bullet. Anyway, I wrote this little bit of code to show you. If you want to test it out then....

1) Save the following code to a PRG file.
NOTE: Don't forget to change the database name
that is shown in red to a file that exists...or make
a small DBF that will fit on the floppy. I created
one with just 3 fields and only 2 records for testing
this code.


2) Insert a blank disk in drive [red]A:[/red] and create a
directory on it and name it [red]TEMP[/red].


3) On your [red]C:[/red] drive, create a directory in the
root of the drive and call that directory [red]TEMP[/red] as well.


4) Start DB and run this program and answer the questions.

5) If you still can't figuer out what you are doing
wrong or you are having problems with these
directions, post again.



**** Start of Code ****

SET TALK OFF
SET ECHO OFF
MyDrive = &quot; &quot;
MyPath = &quot;\temp\&quot;
MyFile = &quot; &quot;
AllMe = &quot;x&quot;
CLEAR
@ 1,3 SAY &quot;Enter Drive Letter (A or C) :&quot; GET MyDrive
@ 3,3 say &quot;Enter an 8 char filename :&quot; GET MyFile
READ
Allme = MyDrive + &quot;:&quot; + MyPath + MyFile + &quot;.dbf&quot;
COPY FILE [red]TestMe.dbf[/red] TO &AllMe
QUIT


**** End of Code ****

Hope this helps some. Let me know one way or the other, in the meantime, good luck.

--MiggyD It's better to have two heads to solve a problem from different angles than to have tunnel vision to a dead end.
 
Well, I guessed it works, huh bkruger?

--MiggyD It's better to have two heads to solve a problem from different angles than to have tunnel vision to a dead end.
 
MiggyD,

Where are my manners... I had no idea how powerful that little & is... Thanks for the help...

Regards, bkruger
 
You're welcomed. I knew you'd find it. It was only a matter of time...Good Job!

--MiggyD It's better to have two heads to solve a problem from different angles than to have tunnel vision to a dead end.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top