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
711 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

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.
In this post we will learn different types of Android Layout and some basics of an Android App.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Progress

696 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