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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

write a html file and FTP it

Status
Not open for further replies.

Mrall

Programmer
Nov 22, 2008
64
0
0
US
Is there a way to write an ascii type file containing html code (and Java) with options gathered from fields in a table?

The file can be created in a .txt because I can rename it to a .html. (unless I can write it directly to a .html)

I know how to write HTML & java so the coding I will write myself, but I need to include options and fields during the file writing process. (a simple example would be nice)

The other question is "What routine is available that will FTP files to a web site?"

Thanks
 
simply use STRTOFILE() to save whatever string (including a HTML source code) to whatever filename, eg

Code:
Local lcHTML

TEXT TO lcHTML NOSHOW TEXTMERGE
<html><body>
Hello, this is a page from <<GetEnv('Username')>>, created at <<DateTime()>>.
</body></html>
ENDTEXT

STRTOFILE(lcHTML,PutFile('Save HTML','vfpcreated.html','html'))

Take a look into the textmerge options, you can also insert options of a html form input control from a vfp table/cursor alias into the html, when you create lcHTML in a Scan..Endscan loop with TEXT TO ... ADDITIVE ...

In the bigger picture creating html and sending it (via FTP or as a server response via Port 80) is rather similar to a web server, there are already several solutions to do so, eg ActiveVFP, AFP (active foxpro pages) and more.

Bye, Olaf.
 
[&nbsp;]

Lots of different ways to generate HTML pages from tables and boilerplate info. I have Foxpro program that generates webpages (HTML & Javascript) from an underlying data base. On a dialup modem it generates and uploads 1400 webpages per hour.

Just extract whichever data you need from your database as you need it, then write to a text file. Once done rename to .html file.

Since STRTOFILE() is not available to me, I just used low level functions and TEXTMERGE.

mmerlinn


"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Steven Raymond
 
Mrall,

As you know, an HTML file is just a text file, and VFP has plenty of ways of creating text files. They include:

- TEXT / ENDTEXT and STRTOFILE() -- as per Olaf's suggesion, above.

- Use the ? command with SET ALTERNATE TO <textfile>

- VFP's Web Publishing Wizard.

You mentioned the need to merge data with fields from a table. You can find an example of that in my article, "Creating an HTML table from a Foxpro table or cursor", which is at
As for uploading the page via FTP, one option is to use the Internet Transfer Control, which comes with VFP 6.0 and above.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
If you can use DOS to FTP try a script like this.

Code:
   lcScript =  "open ftp.yoursite.com" + CHR(10) +;
    "username" + CHR(10) + ;
    "password" + CHR(10)+ ;
    "binary" + CHR(10) + ;                 
    "cd ./TargetDir" + CHR(10) + ;
    "lcd " + lcDataFolder + CHR(10) + ;
    "put " + [file1_]+ DTOS(ldDate)+[.csv]+ CHR(10) + ;
    "put " + [file2_]+ DTOS(ldDate)+[.csv]+ CHR(10) + ;
    "bye"

    STRTOFILE(lcScript,"ftpscript.txt")
    RUN ftp -i -s:ftpscript.txt
[\code]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top