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: https://blogs.msdn.com/calvin_hsia or at https://weblogs.asp.net/calvin\_hsia

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'

            &cCmd

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

            RETURN &cExpr

ENDDEFINE

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

  • Anonymous
    July 24, 2005
    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.

  • Anonymous
    July 24, 2005
    <a href="nu.com">lol</a?

  • Anonymous
    July 25, 2005
    Here’s a way to manipulate photos from within some Microsoft products.
    In the prior post, I wrote some...

  • Anonymous
    August 05, 2005
    Sometimes I need to test something using VBScript. A user sends a code snippet and asks why it behaves...

  • Anonymous
    March 01, 2006
    The comment has been removed

  • Anonymous
    April 07, 2006
    I received a question from a reader:
    &amp;nbsp;
    I decided to extend my VPF9SP1 application to support OLE...

  • Anonymous
    May 01, 2006
    Sometimes it takes many steps to reproduce a problem. Perhaps you have to start an application, log in,...

  • Anonymous
    May 16, 2006
    When I posted this Sample program to create multiple threads, I knew the inevitable follow-up question...

  • Anonymous
    October 24, 2006
    A customer reported a difference in behavior when executing some code in the design time and in a COM

  • Anonymous
    May 16, 2007
    It’s simple to create a VFP object that can be used within other applications. I show how useful it is

  • Anonymous
    May 21, 2007
    The comment has been removed

  • Anonymous
    September 27, 2007
    Somebody in the world is browsing the internet and hits your web site. How do you know? IIS provides

  • Anonymous
    September 27, 2007
    Here I described how VFP generates executable code and runs it for early and late binding COM clients

  • Anonymous
    October 08, 2007
    In my prior post Use new XML Features of VB to generate dynamic scripts and text files , we generated

  • Anonymous
    October 08, 2007
    PingBack from http://www.itsatrap.info/generate-and-run-powershell-scripts-dynamically/

  • Anonymous
    February 25, 2008
    The comment has been removed