Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create text file 1

Status
Not open for further replies.

Jerryyang

Programmer
Feb 15, 2011
8
CA
how to create a text file from VFP?

I want to create a text file with filename: mybackup.txt
with the content:

mysqldump -%1 -%2 %3 > %4

Thanks for the help.
 
Code:
STRTOFILE("mysqldump -%1 -%2 %3 > %4","mybackup.txt")

Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
STRTOFILE() stores a string (as is) into a file. TEXT...ENDTEXT is another possibility.

Code:
* StrToFile is simple in this one line case:
StrToFile('mysqldump -%1 -%2 %3 > %4','C:\somefolder\mybackup.cmd')

* With multiple lines you're better off with TEXT ENDTEXT:
_Text = Fcreate('C:\somefolder\mybackup2.cmd')
Text NoShow
mysqldump -u%1 -p%2 %3 > %4
mysqldump -u%1 -p%2 %5 > %6
mysqldump -u%1 -p%2 %7 > %8
EndText
Fclose(_Text)

Bye, Olaf.
 
As you can see by the two differing approaches above, there are a number of ways that VFP can create a Text file.

Additionally:
1. Use COPY TO with an appropriate option
COPY TO NewTxtFile.TXT DELIMITED
COPY TO NewTxtFile.TXT SDF

2. Use low level functions to Write a Text File
FOPEN()
FPUTS()
FCLOSE()
etc.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top