Using Launch.prg to Launch your Application

Starting with Web Connection 7.0 a Launch.prg file is generated into new projects. This file can be used to quickly launch your Web Connection applications using a number of different start modes. Rather than using the traditional DO MyAppMain.prg you can use Launch.prg to:

  • Launch your FoxPro Server
  • Launch a separate Web Server like IIS Express and/or BrowserSync
  • Launch your Web Browser

all in one single command step.

You can use Launch.prg to work with these servers and combinations:

For more information on BrowserSync and seeing HTML,CSS,Script and JS changes live reloaded in your browser as soon as you save a change to disk, please see the Using BrowserSync topic.

Note: BrowserSync and 'action' commands are new in 7.05. Previously you could only use .t. or .f. for IISEXPRESS and IIS respectively. We recommend you update to the 7.05 model. See below for how you can update your projects to the new Launch.prg implementation.

Launch Modes

Launch.prg supports a number of different combinations of modes.

  • IIS Launches the application without any special server startup since IIS is always up and running. Opens the browser for the IIS URL. Urls include a virtual:
    http://localhost/MyApp.

  • IISEXPRESS
    Launches the IIS Express WebServer on the default port 7000. If already running it'll try to launch again but this has no effect as it's already running. Then starts your Web Connection application and opens a Web Browser on the url:
    http://localhost:7000.

  • BROWSERSYNC or BROWSERSYNCIIS
    Launches the Browser Sync Live Reload NodeJS Component (has to be installed!) as a proxy to IIS. Then launches your Web Connection server and opens the browser on the BrowserSync port of 3000.
    http://localhost:3000/MyApp

  • BROWSERSYNCIISEXPRESS
    Launches the Browser Sync as a proxy to IIS Express. Then launches your Web Connection server and opens the browser on the BrowserSync port of 3000.
    http://localhost:3000/

  • NONE or SERVER
    Launches your FoxPro server without launching any servers or opening a browser.

  • HELP
    Documentation link that opens this Web page

  • Called with no Parameters
    This mode will default to either IIS or IISExpress mode depending on which Web Server you chose during installation. You can modify Launch.prg to set a different startup type to use as your default.

What about: DO AppMain.prg?

Although launch.prg makes it easier to launch applications for the first time to get servers and browsers opened in one step, the traditional direct method of launching your server with DO MyAppMain.prg still works just fine and in fact is still a good way to launch once your server and browser are already open and running.

Updating an Old Application to use Launch.prg

Applications prior to Web Connection 7.05 either didn't have a Launch.prg or had a more limited version. So to take advantage of the above features you need can easily create a new Launch.prg file into your existing project.

To do this:

  • Use the Console to create a New Project
  • Go to the project folder and copy Launch.prg into your existing project
  • Modify the startup parameters in Launch.prg

All of the necessary parameters for Launch.prg are defined at the top of the program so you can easily change the code with the values for your specific project.

The code that needs to be adjusted is the following:

*** Generated Defaults
lcVirtual = "wwThreads"
lcAppName = "wwThreads"
lcScriptMap = "wwt"
lcWcPath = ADDBS("C:\WEBCONNECTION\FOX\")
lcWebPath = LOWER(FULLPATH("..\web"))
llIisExpress = .F.

In this case I updated my Message Board application to use Launch.prg. The changes I made are:

  • Change lcVirtual and lcAppName to wwThreads
  • Change the scriptmap to wwt

And that's it.

Note that lcAppName is the name of your project, while lcVirtual is the name of your Virtual directory (or empty for a root site) in IIS (even if you are not using IIS). In most cases these are the same but they can be different for projects with multiple process classes.


© West Wind Technologies, 1996-2019 • Updated: 05/05/19
Comment or report problem with topic