The Web Connection Server started with the DO WCDEMOMAIN command runs a VFP program. The demo application is also a PRG file that you can edit. So,
If you go back to Visual FoxPro now you should find the debugger popping up on the SET STEP code that we just inserted:
You can now happily step through the code line by and see the operation of each request as it happens. For example, you can now see the content of the request variables
lcOrigClient=Request.Form("Client")
lcDate1=Request.Form("StartDate")
lcDate2=Request.Form("EndDate")being filled and the SQL WHERE clause being built and then rendering the code with ShowCursor().
As you just saw making a code change is very easy - you simply change the PRG file, save it and start up the server again. You don't need to recompile (although you could recompile the WCDEMO project everytime) and the changes take immediately.
o=CREATEOBJECT("NonExistingObject")Guess what will happen here? The code will fail because this object doesn't exist and a VFP error occurs. VFP pops up an error dialog ontop of the editor with the code highlighted:
This is great for debugging - certainly beats typical COM debugging that doesn't allow you to debug a compiled object at runtime, right.
While this is nice for debugging if this occurs on your live Web site, this would be a problem though. I know you don't make coding mistakes ever <s>, but there are system circumstances or typos etc that do slip into production code. A stop error as we're seeing above would lock the Web Connection server dead in its tracks - it wouldn't be able to take any more requests until the dialog is closed.
In order to work around this Web Connection has a configuration setting that allows you to switch between debug and live modes. You can find this flag in WCONNECT.h:
#DEFINE DEBUGMODE .T.
By default Web Connection ships with this flag set to .T. which makes errors basically stop on the offending line of code, since this is great for debugging. In order to switch this flag into deployment mode set the flag .F. and recompile your project. It's very important that you recompile the project completely with:
BUILD EXE <projname> FROM <projname> RECOMPILE
or by using the Recompile All option from the Build dialog.
Rerun the program now by running the EXE file:
DO WCDEMO
Now re-run the request. You'll find that Web Connection now handles the error and passes back an error page that describes the error on the Web page:
This is obviously much nicer than the server crashing and hanging situation we encountered before. What happens behind the scenes is that the Web Connection error methods kick in and generate this HTML output page. The page can be customized by overriding the wwProcess::ErrorMsg() method in your subclass of it. In fact you can also override the error behavior to perform other tasks on errors, but there's not a lot you can do but display some error info. Once the error page is generated the code returns back to the mainline and the error page is returned to the Web browser.
Note: The Shareware version is precompiled, so the #DEBUGMODE flag cannot be set and recompiled. The Shareware version will always stop on any VFP errors in your code.