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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wait window message

Status
Not open for further replies.

channelmaster

Technical User
Dec 9, 2001
52
PH
How can you put the files you are copying in a wait window?
I used RUN XCOPY for my backup and I want to know on how to place a code in the WAIT WINDOW the files that are copying. HELP, PLEASE! thanks,
Rene
 
Local lcFile
LcFile ="myTable.dbf"
wait window "copying "+lcFile NOWAIT
XCOPY lcFile to....

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Hi,

RUN XCOPY for my backup and I want to know on how to place a code in the WAIT WINDOW the files that are copying.

Mikes suggestion will only show the named file variable 'lcFile'. Since XCOPY uses its own way of reading the blocks and copying it, I dont think we can get the file name individualy as they copy.

On the contrary, if an array is made.. say

=ADIR(laFiles,"C:\myData\*.*")
totFiles=ALEN(laFiles,1)
FOR I=1 to totFiles
lcFile = laFiles(i,1)
WAIT WINDOW "Copying "+laFiles(i,1)+" to DriveA:" NOWAIT
COPY laFiles(i,1) TO "A:\"+laFiles(i,1)
ENDFOR

This uses the Copy Command and not XCOPY command.

While I have given this, ChannelMaster has to think about..
1. Changing the floppy when it gets full... to insert next floppy.
2. One file exceeding the size of A drive capacity..
etc.

A better approach will be to use ZIP archive with span ability for multiple disks. OR a CAB arc.

:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Just as a comment to channelmaster:

I have worked in backup projects using xcopy or xcopy32 and found that using VFP's COPY FILE is as fast as xcopy and xcopy32, even when you have to compare modification dates and times, so, as an advice, whenever possible, try avoiding using old-good-DOS commands. One of the problems I found in using DOS commands is that when you use a RUN command, it doesn't wait until it is finished to go into your next program's line of code but instead, it starts the RUN process, this runs in the background and your next line of code is executed, and the next, and the next...

This is specially dangerous when your RUN command is in a loop, let's say you are XCOPYing files from several directories.

This is a problem that took a lot of effort from Chris RChamberlain several months ago when he was trying to help me (even when all of his ideas were a big help).


Good luck


Rianeiro
 
Dear Ramani,
I tried to use your code but when the error was generated:
COPY laFiles(i,1) TO "A:\"+laFiles(i,1)
Error in line 308: Command contains unrecognized phrase/keyword.

Maybe something you might overlook, Pls. help, thanks for all your tips.
 
channelmaster

Ramani may have forgotten one little word

=ADIR(laFiles,"C:\data\*.*")
totFiles=ALEN(laFiles,1)
FOR I=1 to totFiles
lcFile = laFiles(i,1)
WAIT WINDOW "Copying "+laFiles(i,1)+" to DriveA:" NOWAIT
COPY FILE laFiles(i,1) TO "A:\"+laFiles(i,1)
ENDFOR
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Hi
Mike.. I missed to key in that..
The code stands corrected as given below.
*************************************************
=ADIR(laFiles,"C:\data\*.*")
totFiles=ALEN(laFiles,1)
FOR I=1 to totFiles
lcFile = laFiles(i,1)
WAIT WINDOW "Copying "+laFiles(i,1)+" to DriveA:" NOWAIT
COPY FILE laFiles(i,1) TO "A:\"+laFiles(i,1)
ENDFOR
*************************************************
:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Thanks everyone, it works but the problem is it also copies the exe file which cause an error(file in use)but anyway, how can we filter these because i don't want to copy all the garbage files like *.bak, *.err and so on. Is there any way to filter the files that we don't intend to copy it? Thanks in advance!!
 
Channelmaster
Code:
=ADIR(laFiles,"C:\data\*.*")
totFiles=ALEN(laFiles,1)
FOR I=1 to totFiles
   lcFile = laFiles(i,1)
   IF !JUSTEXT(lcFile)="exe"
    WAIT WINDOW "Copying "+laFiles(i,1)+" to DriveA:" NOWAIT 
    COPY FILE laFiles(i,1) TO "A:\"+laFiles(i,1)
   ENDIF
ENDFOR
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
the function justext() does not work for me, I am still using the VFP5.0, any alternative? Thanks again for your help.
 
Channelmaster
the function justext() does not work for me, I am still using the VFP5.0, any alternative? Thanks again for your help.

Yes, the foxtools library has it's own JUSTEXT()

Code:
IF ! "foxTools" $ SET("LIBRARY")
	SET LIBRARY TO FOXTOOLS.FLL ADDTITIVE
ENDIF
=ADIR(laFiles,"C:\DATA\*.*")
totFiles=ALEN(laFiles,1)
FOR I=1 to totFiles
	lcFile = laFiles(I,1)
	IF !JUSTEXT(lcFile) ='EXE'
	  WAIT WINDOW "Copying "+laFiles(i,1)+" to DriveA:" NOWAIT
        COPY FILE laFiles(i,1) TO "A:\"+laFiles(i,1)
	ENDIF
ENDFOR
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Dear Mike
Thanks for that tip and everytime I get a successfull tip I am becoming more bolder. This time how can we place that code with a progressbar? Thanks a lot in advance and God bless.
 
Dear Mike,
Is there any possibility to make a progressbar out of thses code below:


IF ! "foxTools" $ SET("LIBRARY")
SET LIBRARY TO FOXTOOLS.FLL ADDTITIVE
ENDIF
=ADIR(laFiles,"C:\DATA\*.*")
totFiles=ALEN(laFiles,1)
FOR I=1 to totFiles
lcFile = laFiles(I,1)
IF !JUSTEXT(lcFile) ='EXE'
WAIT WINDOW "Copying "+laFiles(i,1)+" to DriveA:" NOWAIT
COPY FILE laFiles(i,1) TO "A:\"+laFiles(i,1)
ENDIF
ENDFOR

Thanks again in advance
 
channelmaster

Unfortunately its always difficult to estimate the size of the files to be copied and the number of files to be copied. I think as Windows itself does, the best way to show a user that files are being copied is by using the copy.avi animation found on your system. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Dear Mike
I'm sorry because I am not a full pledge VFP programmer, can you please elaborate the "copy.avi" term, and how will I do it? Thanks for your patience.
 
channelmaster

Sorry I meant "filecopy.avi". Depending on the version of FoxPro you have. I have one located here "C:\Program Files\Microsoft Visual Studio\Common\Graphics\Videos" for VFP6.0. Its a little animation file that looks the same as when you copy a file with Windows Explorer. You would create a form an put a movie activex on the form a play the animation while your file is being copied. The is a sample of how to play an animation in the "Solutions" that came with VFP. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
channelmaster

You have enough data to be able to use a progressbar with the following code modified from your own.

lnFiles = ADIR(laFiles,[C:\DATA\*.*],[A])
lnTotal = 0
FOR i = 1 to lnFiles
[tab]IF !JUSTEXT(laFiles(i,1)) ='EXE'
[tab][tab]WAIT WINDOW "Copying "+laFiles(i,1)+" to Drive A:" NOWAIT
[tab][tab]COPY FILE laFiles(i,1) TO "A:\"+laFiles(i,1)
[tab][tab]lnTotal = lnTotal + 1
[tab]ENDIF
ENDFOR


If you use the code in faq184-2366, you need to include the following code in your FOR...ENDFOR loop

WITH THISFORM
[tab].txtProgressBar.Value = ;
[tab][tab]ALLTRIM(STR((lnTotal / lnFiles * 100))) + [%]
[tab].shpProgressBar.Width = ;
[tab][tab]lnTotal * THISFORM.txtProgressBar.Width / lnFiles
ENDWITH


If the progressbar doesn't refresh properly, put INKEY(0.5) in the loop to enable the controls to display their new values.

lnFiles = ADIR(laFiles,[C:\DATA\*.*],[A])
lnTotal = 0
lnNoCopy = 0
WITH THISFORM
[tab]FOR i = 1 to lnFiles
[tab][tab]IF !JUSTEXT(laFiles(i,1)) ='EXE'
[tab][tab][tab]WAIT WINDOW "Copying "+laFiles(i,1)+" to Drive A:" NOWAIT
[tab][tab][tab]COPY FILE laFiles(i,1) TO "A:\"+laFiles(i,1)
[tab][tab][tab]lnTotal = lnTotal + 1
[tab][tab]ELSE
[tab][tab][tab]lnNoCopy = lnNoCopy + 1
[tab][tab]ENDIF
[tab][tab].txtProgressBar.Value = ;
[tab][tab][tab]ALLTRIM(STR((lnTotal / (lnFiles - lnNoCopy) * 100))) + [%]
[tab][tab][tab].shpProgressBar.Width = ;
[tab][tab][tab][tab]lnTotal * THISFORM.txtProgressBar.Width / (lnFiles - lnNoCopy)
[tab]ENDFOR
ENDWITH
FAQ184-2483 - the answer to getting answered.​

Chris [pc2]
 
Dear Chris,
Sorry it takes me longer to response again, anyway I have been trying to use your code with progressbar, but something is wrong. Your code works fine but there is an error "file is in use". I tried to figure out what file is in use and I finally found out that the culprit is the name of the form which the progress bar is placed. It seems that the code above cannot copy the form during runtime. Is there any solution to these? Thanks again.
 
If you are really running the .EXE that a project with this form is included in created, you won't have this problem. The alternative is to extend the exclusion check:
Code:
IF !JUSTEXT(laFiles(i,1)) ='EXE'
to include other files, OR use a lowlevel FOPEN() to see if the file is in use and skip it.

Rick

 
You'll have to add soemthing like:

IF !JUSTEXT(laFiles(i,1)) ='EXE' ;
AND (UPPER(laFiles(i,1)) # 'MYFORM.SCX' AND UPPER(laFiles(i,1)) # 'MYFORM.SCT')

WAIT WINDOW "Copying "+laFiles(i,1)+" to Drive A:" NOWAIT
COPY FILE laFiles(i,1) TO "A:\"+laFiles(i,1)
lnTotal = lnTotal + 1
ELSE
lnNoCopy = lnNoCopy + 1
ENDIF

where MYFORM is the name of the form you want it to skip.
Dave S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top