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


\  XCOPY <<ALLTRIM(name)>> <<mdrive>><<ALLTRIM(mdirletter)>> /s /e /y
\    PAUSE
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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.)
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

awesome.  glad it worked,


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hi lessel -

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


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.