how to create a batch file within a foxpro 2.6 program that contains memory variables neede to create the text for the batch program

I wrote a small program in Foxpro 2.6  <mbatch.prg> , using memory variables,  that creates a batch file <path.bat>  that copies directories and sub directories to a user created Drive. Everything looks fine when reviewing the batch file. When running it, however, an error message appears "Invalid Path". If I were to substitute memory variables with the actual path the batch program works fine. It appears that the program <mbatch.prg> is creating formatted text. how can I correct this problem.  

Program: <mbatch.prg>
************************************************************************

* The purpose is to copy a folder to a different directory

*<mdrive> was created from a user defined directory in calling program
*<name> is a field taken from an open database. Each record is a path to a given  folder;
               ie: (c:\imp_inv\data\) chosen by user in calling program  

mdirletter = SUBSTR(name,2,30)  && used so the same folder name can be copied to a ;
                                                           differen drive letter

SET TEXTMERGE ON  NOSHOW

 SET TEXTMERGE  TO path.bat
 
\  XCOPY <<ALLTRIM(name)>> <<mdrive>><<ALLTRIM(mdirletter)>> /s /e /y
\\  
\    PAUSE
\\
  SET TEXTMERGE OFF  
************************************************************************
lesselAsked:
Who is Participating?
 
jsrebnikCommented:
awesome.  glad it worked,

cheers!
0
 
jsrebnikCommented:
Here's another approach.  It's much easier to write data from variables into a field in a table.  For example :

Create a dbf file called batfiles.dbf.  It can have one field, filecmd Char (200).

Write your code so that you end up with the content you want in the batch file in that field.

For example:

REPL filecmd with "XCOPY "+allt(name) + " " + mdrive + " " + allt(mdirletter)" + "/s /e/y"  

when you have what you want in the field:

copy field filecmd to path.bat type sdf
0
 
GEOFSCommented:
Have you tried using function STRTOFILE()?  (After I typed that question I realized that the function may not have existed in version 2.6, which would make it very difficult to use, I think.)
0
 
lesselAuthor Commented:
Thanks jsrebnik (37761432) it works perfectly. A very simple solution. The only thing that I had to change the character field to  a memo field and did a <COPY MEMO  field TO file>.

Thanks again

lessel
0
 
jsrebnikCommented:
hi lessel -

i'm cleaning up some of my monitored questions.  can you mark the question as answered at your convenience?

thanks,

jsrebnik
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.