Solved

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

Posted on 2012-03-23
5
652 Views
Last Modified: 2012-04-13
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  
************************************************************************
0
Comment
Question by:lessel
  • 3
5 Comments
 
LVL 2

Expert Comment

by:jsrebnik
ID: 37761432
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
 
LVL 2

Expert Comment

by:GEOFS
ID: 37763682
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
 

Author Comment

by:lessel
ID: 37764376
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
 
LVL 2

Accepted Solution

by:
jsrebnik earned 175 total points
ID: 37779937
awesome.  glad it worked,

cheers!
0
 
LVL 2

Expert Comment

by:jsrebnik
ID: 37842365
hi lessel -

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

thanks,

jsrebnik
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question