J.M.
I see your logic as your are checking that the
scratch directory is already set, hadn't thought
of that one. I see the way you are copying a file,
and I think that's a good idea. There are a couple
of things about your routine that bewilder me.
1. The SYNTAX says that if you use wildcards with
the CHKFILE function you may get back bad results
so I don't use that method.
2. The [EMAIL PROTECTED] I don't know what this is
at all. I'll have to look into this one.
Here is the code I am using to date: In a few weeks I
will be moddfying all my applications to all go to one
default "connection" database and user info/connections/
rights and so on will be handled from it. For now this
has to do:
SET VAR vg_user = (CVAL('NAME')) --Gets the User name from the rbase.cfg
file
SET VAR vg_pwd = NULL --done as the default here, but used in places
where
--required with a SELECT statement.
SET VAR vg_user = (.vg_user + ' ' + .vg_pwd)
SET USER &vg_user
SET VAR vg_db TEXT = NULL
SET VAR vg_temp TEXT = NULL
SET VAR vg_temp = (ENVVAL('TEMP')) --Check to see if Environment var is
set
IF vg_temp IS NOT NULL THEN
SET SCRATCH .vg_temp
SET VAR delfiles TEXT = ('ERASE ' + .vg_temp + '\' + '*.$$$')
&delfiles
ELSE
SET VAR vg_dir INTEGER = (CHKFILE('C:\WINNT\TEMP'))
IF vg_dir = 1 THEN
SET VAR vg_temp TEXT = 'C:\WINNT\TEMP'
SET SCRATCH .vg_temp
SET VAR delfiles TEXT = ('ERASE ' + .vg_temp + '\' + '*.$$$')
&delfiles
ELSE --c:\winnt\temp does not exist, try another route.
SET VAR vg_dir INTEGER = (CHKFILE('C:\WINDOWS\TEMP'))
IF vg_dir = 1 THEN
SET VAR vg_temp TEXT = 'C:\WINDOWS\TEMP'
SET SCRATCH .vg_temp
SET VAR delfiles TEXT = ('ERASE ' + .vg_temp + '\' + '*.$$$')
&delfiles
ELSE
SET VAR vg_temp = (CVAL('CURRDIR'))
-- will be the directory the database
-- is in since we are connneted
SET SCRATCH .vg_temp
SET VAR delfiles TEXT = ('ERASE ' + .vg_temp + '\' + '*.$$$')
&delfiles
ENDIF
ENDIF
ENDIF
SET VAR vg_tmpdir TEXT = .vg_temp
CONNECT mpofile IDENTIFIED BY &vg_user
IF errvar <> 0 THEN
PAUSE FOR 2 USING 'ERROR: Could not connect to database' AT CENTER
CENTER
CLEAR VAR vg_temp, vg_dir, delfiles
SET VAR vg_db = NULL
SET DATE FORMAT MM/DD/YYYY
SET DATE SEQUENCE mmddyy
SET DATE CENTURY 19
SET DATE YEAR 50
RETURN
ENDIF
SET VAR vg_db = (CVAL('Database'))
SET DATE FORMAT MM/DD/YYYY
SET DATE SEQUENCE mmddyy
SET DATE CENTURY 19
SET DATE YEAR 50
CLEAR VAR vg_temp, vg_dir, delfiles
SET FILES 60
I will likely try to encorporate your file copying technique.
Greatly apprciated
Jim Limburg
"J.M. GRATIAS" wrote:
>
> Jim :
>
> >>
> Do you SET SCRATCH blah blah before you connect to
> the database or connect to the database and then set scratch?
> <<
>
> SCRATCH must be set BEFORE DB connection, and BEFORE any work that could
> generate a scratch file.
> Keep also in mind that scratch directory must exist and must be avalaible
> in write mode.
> If not, you can have many unexplained troubles (I have experimented that)
> ....
>
> Here is the code I run before lauching all my app :
>
> -- Controle existence et accessibilit� r�pertoire Scratch
> SET VAR vscratch = (CVAL('SCRATCH'))
> SET VAR vTEXT = (.vscratch + '\*.*')
> SET VAR vINT = (CHKFILE(.vTEXT))
> IF vINT = 0 THEN
> -- Le r�pertoire SCRATCH n'existe pas
> SET VAR vTEXT = ('Cr�er le r�pertoire SCRATCH (' + .vscratch + ') et
> relancer')
> -- 16 = 1 seul bouton, arr�t critique
> SET VAR vTEXT = ('16|' + .Vcaption + '|' + .vTEXT)
> SET VAR vTEXT = (UDF('@RMSG.DLL',.vTEXT))
> QUIT
> ELSE
> -- Il existe ... Tentative de copie
> COPY rbase.dat .vscratch
> SET VAR vINT = .verr
> IF vINT <> 0 THEN -- Le r�pertoire SCRATCH est inaccessible
> SET VAR vTEXT = ('Ecriture impossible sur le r�pertoire SCRATCH (' +
> + .vscratch + '). Erreur' & (CTXT(.vINT)))
> SET VAR vTEXT = ('16|' + .Vcaption + '|' + .vTEXT)
> SET VAR vTEXT = (UDF('@RMSG.DLL',.vTEXT))
> QUIT
> ELSE -- Effacement du fichier copi�
> SET VAR vTEXT = (.vscratch + '\rbase.dat')
> DELETE .vTEXT
> ENDIF
> ENDIF
>
> Hope this help ....
>
> J.M. GRATIAS, Logimatique, France