Microsoft KB Archive/168053

From BetaArchive Wiki

Article ID: 168053

Article Last Modified on 7/13/2004



APPLIES TO

  • Microsoft Visual FoxPro 5.0 Standard Edition
  • Microsoft Visual FoxPro 5.0a
  • Microsoft Visual FoxPro 6.0 Professional Edition



This article was previously published under Q168053

SUMMARY

Microsoft Internet Information Server (IIS) 3.0 supports Active Server Pages (ASP). ASPs allow you to perform server-side processing and scripting through the use of automation servers, including automation servers that were created in Visual FoxPro 5.0 or 6.0. This article demonstrates how to use a Visual FoxPro automation server with Active Server Pages.

MORE INFORMATION

There are primarily two components:

  • Visual FoxPro Automation Server.
  • Active Server Page that instantiates the server.

The Visual FoxPro Automation Server

For this example, you can create a simple automation server in Visual FoxPro. This automation server has two methods: one called GetTime(), which will return the current time and one called GetDate(), which will return the current date.

Creating the automation server:

  1. Create a new project named ASPSrv in Visual FoxPro.
  2. Add a new program to the project with the following code:

            DEFINE CLASS WristWatch AS Custom OLEPUBLIC
    
          PROCEDURE GetTime()
             RETURN Time()
          ENDPROC
    
          PROCEDURE GetDate()
             RETURN Date()
          ENDPROC
    
            ENDDEFINE
  3. Build the project into an OLE DLL automation server.
  4. Install the automation server onto your IIS 3.0 server.

    NOTE: It is recommended that you use the Setup Wizard in Visual FoxPro as a distribution method. Files that will be included for distribution are the Visual FoxPro runtime, the OLE server .DLL, .TLB, and .VBR files.

The Active Server Page

The ASP file is the component that instantiates the automation server and calls the methods of the automation server.

  1. Create the following file in a text editor, such as Notepad:

         <%@ LANGUAGE="VBSCRIPT" %>
         <!-- Ensure that there is a space before LANGUAGE and
              after "VBSCRIPT" -->
         <HTML>
         <HEAD>
         <TITLE> VFP and ASP </TITLE>
         </HEAD>
    
         <BODY>
         <H2>Active Server Pages and Visual FoxPro Automation Servers</H2>
    
         <%Set VFPSrv = Server.CreateObject("ASPSrv.WristWatch")%>
    
         Today's Date is <%=VFPSrv.GetDate()%>
         <P>
         The Current Time is <%=VFPSrv.GetTime()%>
    
         </BODY>
         </HTML>
                        
  2. Save this file to your IIS WWWROOT directory as VFPSrv.ASP, and make certain that this directory has Execute privileges.
  3. You should now be able to access this Active Server Page from your Web browser. The page should show the current date and time from the server.


Keywords: kbhowto kbinterop kbautomation KB168053