files on external drives

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

Templar
Posts: 51
Joined: Sun Apr 01, 2018 5:37 pm
DBs Used: DBF

files on external drives

Post by Templar »

Can you "USE" a data file off a different drive?

eg: ( If my installation is on C:\ drive )
A command like USE E:\BOOKS\AUTHORS.dbf
will not actually open the file. It can find it okay, so:

IF FILE("E:\BOOKS\AUTHORS.dbf")
USE E:\BOOKS\AUTHORS.dbf
ELSE
< Display some error message >
ENDIF
does not display the error message, but it does nothing!!
Any suggestions how to get round this?
Templar
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: files on external drives

Post by andyglezl »

Porque utilizar la letra de la unidad ?

Cuando ejecutas tu programa, asume que tus bases de datos se encuentran
en la carpeta (o tu le indicas las subcarpetas ) de donde está arrancando.

Si te fijas, todos los ejemplos de HMG,
NO UTILIZAN la letra de la unidad.

USE AUTHORS

Debería de ser suficiente.
*-------------------------------------------------------------------------------------------------
Why use the drive letter?

When you run your program, assume that your databases are
in the folder (or you indicate the subfolders) where it is booting from.

If you look, all the HMG examples,
DO NOT USE the drive letter.

USE AUTHORS

It should be enough.
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: files on external drives

Post by mol »

try to use

Code: Select all

SET PATH TO E:\BOOKS
you can also use list of your locations separated by semicolon

You can also use SET DEFAULT TO [xcPatspec]

Sample from Clipper 5 manual:

Code: Select all

set default to e:\books
? file("authors.dbf")    //result: .T.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: files on external drives

Post by mol »

Templar wrote: Wed Mar 25, 2020 5:12 pm Can you "USE" a data file off a different drive?

eg: ( If my installation is on C:\ drive )
A command like USE E:\BOOKS\AUTHORS.dbf
will not actually open the file. It can find it okay, so:

IF FILE("E:\BOOKS\AUTHORS.dbf")
USE E:\BOOKS\AUTHORS.dbf
ELSE
< Display some error message >
ENDIF
does not display the error message, but it does nothing!!
Any suggestions how to get round this?
Templar

The simplest way is to use DbUseArea("e:\books\authors.dbf")
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: files on external drives

Post by AUGE_OHR »

hi,

you talk about external Drive ... is it a USB-Drive or Network-Drive :?:

if USB-Drive : check Attribut if File have "R"eadonly Flag
can you open that DBF when copy to your Home-Directory. :?:
have fun
Jimmy
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: files on external drives

Post by SALINETAS24 »

Hola Auge.., igual es esto lo que buscas.

Code: Select all


cFile:="E:\BOOKS\AUTHORS.dbf"

IF FILE("E:\BOOKS\AUTHORS.dbf")
	USE (cFile)
ELSE
    < Display some error message >
ENDIF

Abrazos virtuales.., y vamos con la cervecita....
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
Templar
Posts: 51
Joined: Sun Apr 01, 2018 5:37 pm
DBs Used: DBF

Re: files on external drives

Post by Templar »

Thanks to everyone for suggestions. Let me explain more.
I am writing a program to install my main package elsewhere. So first I copy all the necessary files from the C:\ drive onto the flashdrive at E:\. Then I want to open one of those files off the flashdrive.
Andyglezl: thanks, but I can't change the default, because I am still using files off C:\ as well.
Mol: Thanks but same thing. I need to use files off two different drives
Auge_ohr: Nope! Checked the Read Only flag. It isn't set
Salenitas24: Thanks, but actually I am enfolding it in a variable. I just simplified it for my example!

The file is certainly there: I can see it in File Explorer and the program checks it is there before trying to open it. So what happens is that it goes through "USE books.dbf" with no error message, but then "GO TOP" produces an error message: "Workarea not in use"

It's odd!
Templar
User avatar
serge_girard
Posts: 3162
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: files on external drives

Post by serge_girard »

Templar,

File is maybe corrupt?
Try another file.

Serge
There's nothing you can do that can't be done...
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: files on external drives

Post by mol »

Try to prepare working sample producing error.
Some of us have a lot of time now...
RPC
Posts: 281
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Re: files on external drives

Post by RPC »

mol wrote: Sun Mar 29, 2020 5:46 pm Some of us have a lot of time now...
Hi mol
Maybe you can help in my memory problem which I posted here ;)
Rajeev
Post Reply