Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
779 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 700 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Introduction to Processes

886 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