Blogs get 300 hits per hour: Visual FoxPro can count.

I wanted to get a picture into my blog, which isn’t run by my web site. It actually gets posted to 2 URLs: or at


I can view and edit my entry in HTML, so I just added an IMG HTML tag pointing to an image on my web site.


Because my web site is actually a computer fully under my control, it counted the number of requests for the picture. It also noted the source of the request (the HTTP_REFERER) and does a SQL Insert to log the data into a Visual FoxPro database.



The web site just has a simple .ASP page with a simple script to invoke a VFP program called DISPATCH.PRG, passing the 3 IIS server objects Request, Response and Server.


This is the entire ASP script:

set session(“ox”) = server.CreateObject(“t1.c1”)

set ox = session(“ox”)

ox.mydocmd(“set path to ” + request.servervariables(“APPL_PHYSICAL_PATH”))

response.write ox.myeval(“Dispatch(p2,p3,p4)”,request,response,server,0)

ox.MyDoCmd(“clear program”)



The t1.c1 object has only a couple lines of VFP code. This is the entire code:


DEFINE CLASS c1 as session olepublic

      proc MyDoCmd(cCmd as string,p2 as Variant,p3 as Variant,p4 as Variant,p5 as Variant) helpstring ‘Execute a command’


      proc MyEval(cExpr as string,p2 as Variant,p3 as Variant,p4 as Variant,p5 as Variant) helpstring ‘Evaluate an expression’

            RETURN &cExpr



The “&” is a macro expansion which means to interpret the value as an executable string. Thus the Dispatch cmd expands to:

            RETURN Dispatch(request, response, server,0)


The Clear Program command allows me to change the server code without shutting it down.


The Dispatch program just returns an HTML string (or it can do a response.redirect)


FoxPro’s powerful text manipulation and local database engine combine to make serving web pages simple.


For more information, here’s a 1996 article I wrote on using VFP to serve up web pages and my 2001 article on Microsoft Visual FoxPro and Advanced COM

Comments (17)

  1. Koen de Jong says:

    I strongly dislike dynamic pages and lots of typing so I use my own Visual Basic application to serve my singlepage website.

    this is also rather secure; and with built-in logging.

  2. kurt says:

    <a href="">lol</a?

  3. Here’s a way to manipulate photos from within some Microsoft products.

    In the prior post, I wrote some…

  4. Sometimes I need to test something using VBScript. A user sends a code snippet and asks why it behaves…

  5. A customer asks if drag/drop is available in a COM server.

    Contrary to what some (wOOdy &amp;lt;g&amp;gt;) believe,…

  6. I received a question from a reader:


    I decided to extend my VPF9SP1 application to support OLE…

  7. Sometimes it takes many steps to reproduce a problem. Perhaps you have to start an application, log in,…

  8. When I posted this Sample program to create multiple threads, I knew the inevitable follow-up question…

  9. A customer reported a difference in behavior when executing some code in the design time and in a COM

  10. It’s simple to create a VFP object that can be used within other applications. I show how useful it is

  11. Run the Fox code in Allowing Optional parameters in your COM objects (or the one in Blogs get 300 hits

  12. Somebody in the world is browsing the internet and hits your web site. How do you know? IIS provides

  13. Here I described how VFP generates executable code and runs it for early and late binding COM clients

  14. In my prior post Use new XML Features of VB to generate dynamic scripts and text files , we generated

  15. While writing software over a period of weeks or months, various components of the software get completed