This session, Visual FoxPro, the Internet, and You will focus
on the issues involved with connecting Internet users to your data!
Why are we here?
- The Internet is growing fast, and as it grows, people want more ways
to deliver data to Internet users. The World Wide Web is certainly
the medium of choice for disseminating data, and will continue to
become more versatile as its use grows.
- for example, on FoxPro-L
and comp.databases.xbase.fox,
this topic has been very popular.
- An Internet mailing list (FoxWeb-L-Request@dsw.com) and work group has formed
around this issue.
- Now that CIS offers World Wide Web access, this will probably become
an issue on FoxForum, if it hasn't already.
What are we doing?
- In this session, I am going to show you a technique that I have
developed for connecting VFP to the Web.
- No, this is not a secure link :-) The Web server that I am using
does not provide any of the public key encryption features that other
servers provide.
What is the World Wide Web?
- You're looking at one part of it right now!
- Global collection of connected documents
- HyperText format, connected by links
- MultiMedia (you can embed graphics, sound, video, etc.)
- Browsable by graphical and character mode clients
- Accessible over the Internet
Web Pages
The documents available on the World Wide Web are known as Web Pages.
- Stored in a format known as HTML (hypertext markup language)
(simple html example)
- May contain graphics, text, and other objects (such as embedded sounds)
- Can call executables (scripts) on web server
- Supports data entry via forms
- Due to the fact that one document can contain many links, many of the
Web pages on the net are connected. As a result, it is possible for there to
exist thousands of ways for people to ultimately "stumble across" your Web
page.
Tools
We are using three tools in these examples:
- https
- the Web Server
- perl
- the Scripting Language
- Visual FoxPro
- the Query Engine
https Intro
- Serves up the Web Pages
- Freeware (copyrighted by the European Microsoft Windows NT Academic Centre)
- your web pages reside in a data directory, and all paths to
your Web pages are referenced as if that directory were the root.
For example, if E:\HTTPS is your data directory, the link to the file
E:\HTTPS\BRIAN.HTML will look something like:
http://myhost.mydomain/BRIAN.HTML
- when https coordinates any requests to run a script, it runs the
requested executable (in this case, perl.exe). https sends arguments
to the script either through environment variables or standard i/o.
- When the script is done running, it will have sent HTML back to
https using standard i/o. This becomes the page that the users see as
a result of running the script.
perl Intro
- the Practical Extraction and Reporting Language (aka the
Pathologically Eclectic Rubbish Lister)
- C, awk, sed, and shell scripts rolled into one
- helpful in automating system tasks
- 32-bit console app which means it uses standard i/o
- why am I not running VFP each time a request comes in?
50 requests at once means 50 instances of the script app - 50 invocations
of perl is a lot more processor friendly than 50 invocations of VFP!
Basic perl examples
Vanilla Perl Sample
Vanilla Perl Sample Src
Installing perl and https
both have uninstall features!!!!
- perl
- Find a home directory for perl. Run the INSTALL.CMD that comes
with the distribution. Start up a new command shell to get the new PATH
settings.
If the web server seems to have a problem running perl, put a copy
in the https data directory.
- available on
-
ftp://mirrors.aol.com/pub/cica/pc/win3/nt/ntperlb.zip
- Windows Shareware Forum on CIS
- https
- Move https.exe, https.hlp and https.cpl into your \winnt35\system32
directory (%systemroot%\system32)
- Type https -install.
- Set up the data directory using the control panel
- Simply type net start "http server" to run it.
- available on
- http://emwac.ed.ac.uk/html/internet_toolchest/https/contents.htm
- Microsoft Windows NT 3.5 Resource Kit
VFP and Perl
xbase.pl
- perl library for interacting with vfp tables
- inserts and reads from dbf files
- primitive, yet effective
Why use perl?
- makes it easy to port the web server portion of these examples to
other platforms
- could run vfp on an intel box, with httpd and perl running on a
unix box
- large networks with unix gateways to the Internet and intel boxes
as workstations are common
vfp and html
The more advanced examples require that vfp generate the html documents
that perl sends to https, ultimately ending up on the user's web browser.
To this end, I have created html.prg - a class library for generating
html documents.
- class - htmlpage
- class - htmlobj
- htmlform - container class which holds form elements
- htmlinput - input region for forms
- htmlheader - header for html documents
- htmllink - html link to other documents or resources
- htmllist - html list base class
- class - htmllist
- definitionlist
- unorderedlist
- orderedlist
- menulist
- directorylist
Advanced Connectivity
querysrv.scx
Tables
- qspoll
- qp_method - what to do (update, insert, skip, skip-1, blank)
- qp_dbc - name of dbc, if relevant
- qp_table - name of table
- qp_fields - space delimited list of fields (for retrieval)
- qp_query - differs based on request
- qp_form - name of form to create, if any
- qp_script - name of perl script used for retrieval requests
- qp_title - title for generated form
- qsfields
- qf_parent - link to qspoll.qp_query for inserts/updates
- qf_fields - name of the field
- qf_value - the value to insert or update
Methods
- timer1.timer
- opens polling tables
- locks request records
- examines request type
- sends record retrieval requests (skip, skip-1, top, blank) to
qsbuildhtmlform
- sends update/insert requests to qsupdate
- querysrv.qsbuildhtmlform
- creates an html page
- locates the record requested
- adds a form object
- adds fields to the form
- adds links to other actions (skip, add, etc.)
- qsupdate
- recognizes one type of primary key (character type, padded on left
with zeros)
- if an insert is requested, figures out the name of the
primary key and calls a dbc stored procedure nextid() to get the
value
- inserts or updates the record in question
Visual FoxPro Query Interface
src
Form example with table
Form example with a view
Last, but not least, the HTML Wizard!!!
Resources
Where do I download the latest version of this stuff???
ftp://spiderweb.com/public/win_nt/http/vfpinet.zip
My email address:
bjepson@conan.ids.net
Some Web Pages
Windows NT Resource Center
EMWAC Web Server
The FoxPro I/O Address
FoxPro Yellow Pages
Other Related Internet Resources
FoxPro Discussion List: FoxPro-L-Request@dswi.com
Include in the subject the word: subscribe
Windows NT discussion list: mailbase@mailbase.ac.uk
Include in the body of your message: join windows-nt Firstname Lastname
Windows NT perl discussion list: Majordomo@mail.hip.com
Include in the body of your message: subscribe ntperl
FoxHtml Discussion list: FoxWeb-L-Request@dsw.com
Include in the subject or body the word: subscribe