newman     VBWeb     VBSource     Portfolio    
OUT ON THE INTERNET


Home

Getting Started
- Hello World Example
- SampleMain Example
- Code Snippets
- Request Collection
- Missing Terms
- Multi-Select
- Names Collection

User Guide
- Debugging
- Stepping Through Code
- HTML Templates
- Cookies

Command Reference
- AddToRequest
- BackupRequest
- CgiDebugPrint
- ErrorHandler
- Escape
- Extract
- FileContents
- FileExists
- GetRequest
- GmtDate
- IsVBIDE
- LoadRequest
- Parse
- Redirect
- Replace
- Send
- SendLn
- ServerVariables
- SetCookie
- StandardIn
- UrlDecode
- UrlEncode

Appendix
- Web Server Directory Mapping
- Computer Name & IP Address

Stepping Through Code

DEBUG

TEMPLATES
For the typical VB program, the programmer can set break points and step slowly through the execution while checking the values of variables. You can do that with VBWeb as well but it takes a trick. The problem is if you try running a script right from within the VB editor, it won't get any entries to process. It needs to get a request such as a query string or entries in an HTML form. That usually means that the script must be an executable. To get around this, VBWeb writes a backup of the request out to a file when it is run as an executable and restores the request when it is run from within the VB editor. Since writing the file can add to the response time of the script, the backup is only made if the IsCgiDebugOn variable is set to True. This instruction should come before the call to LoadRequest. For example:
Public Sub Main()
On Error GoTo Trap
IsCgiDebugOn = True
Call LoadRequest
Call ProcessRequest
Exit Sub
Trap:
Call ErrorHandler("")
Exit Sub
End Sub
Once this line is added, the script must be compiled and then run from the web site. After that, return to the VB editor and step through the code as you see fit.

Workstation User Tip: If you edit the project from a different directory than the executable in the web server, then you will need to retrieve the backup file and move it to the current directory. This is usually the directory containing the VB project file.

If you do not have a VB error that needs fixing, we can find one in a demo application.
  1. If you have not yet done so, download and install the vbshop demo project. There are instructions in the NEWMAN VBWeb web site.

  2. Next, we find an error. You can cause an error by clicking Check Out when the shopping cart is empty. Once you see the error, don't do anything else with the site. At this point, the request has been backed up. If you cause another request, it will get backed up and written over the one we want. Your browser should show the following error:
    A Message from the Server
    The server had trouble processing your request. Back up and try again.
    Nothing has been ordered yet. (10000).
  3. Open the vbshop project in the VB editor and and run it. This is when VBWeb gets a chance to restore the backup so that vbshop runs just as it did for the browser. And that's when the following error message pops up. Click Debug to see just where the error occurred.

How to only back up your own requests.
The IsCgiDebugOn line as coded above, causes every request to get backed up. If another visitor sneaks in shortly after you find an error, a new backup gets written over the one you want. To prevent this, you can restrict backups to only the requests that come from you and your browser. To do this, find your IP address and use it in the following way:
If Environ$(CGI_REMOTE_ADDR) = "256.256.256.256" Then
IsCgiDebugOn = True
End If
top

DEBUG

TEMPLATES


Copyright 1997 NEWMAN Services Corp. All rights reserved.
973-228-5753 pres@newmanservices.com