Debugging and Running Your Program

Finally, we are just about ready to actually run our web server program. There is only a little more preparation left to do so that we can run our program. First, to make our lives simpler, we need to add a secondary target for the build process. We do that by opening the Project Settings window and this time selecting the third tab labeled Targets, as shown in the picture below:

The Targets tab of the Project Settings window

The Targets tab of the Project Settings window

Click on the Edit/Add Target button. This displays the Target Manager window. On the left side of the window is a place to store common target directory names. On the right is a place to store common shebang lines.

[Note]What's a shebang line?

In some operating systems, most notably UNIX, Linux, and now Mac OS-X, it is common to place a special type of comment at the beginning of a script that is marked as executable by the operating system. This comment must be the first line of the script and begins with a comment symbol, the hash mark (#) followed by the exclamation point symbol (!) (sometimes called the bang symbol – presumably from its use in comic books). This combination the "hash bang" has come to be known as the shebang. Directly following this character combination is the path and file name of the program that should be used to execute the script that follows. Programs that are aware of this convention and which support it can use this method of determining the correct processing program so that the script name alone is sufficient to run the script. The line must end with an end of line character that is correct for the target platform. On Windows and DOS machines this is the carriage return linefeed combination 0x0D-0x0A. On UNIX, Linux, and Mac OS-X this is 0x0A alone.

Create a target such as the one shown in the picture below. Make sure to use the correct path names for wherever you installed the Simpol Developer Kit product. You may wish to add the target directory and shebang lines to the lists since you will probably use them often. In this case we are creating a debug target. The program called sbngidecaller.exe is used to make direct callbacks into the IDE.

Creating our new target for learn02.smp

Creating our new target for learn02.smp

Don't forget to activate the target! Then click the OK button to create the target and then the OK button to save the changes. Finally, press Ctrl-B to rebuild the project and create the secondary target.

[Warning]Warning

If you are using Windows 9x, you can't use the sbngidecaller.exe program! This program is implemented using named pipes which are not available on the Windows 9x operating system. Instead, to debug a program you can start the IDE with the "/d" command line parameter. The shebang line would then look like this:

#!C:\SIMPOL\BIN\SBNGIDE.EXE /d{d}{a}.

This will start another instance of the IDE each time a call is made to the script. It is not as convenient as the other method, but at least it is still possible to debug on Windows 9x!

Now open a browser window if one is not still open and enter the URL http://localhost/cgi-bin/learn02.smp and press the ENTER key. The following picture should appear on your desktop if you are using the SIMPOL redirector program called sbngidecaller.exe.

Request to debug program

Request to debug program

This message is from the IDE indicating that it has received a request to debug a program. If that program is not the current one in your IDE the current project will be closed and the project associated with the program to be debugged will be opened. At this point everything runs exactly the same as when debugging normally so we won't go into the details of that. Simply click on the OK button and then press F5 to let the program just run through (it shouldn't have any errors in it this time, if it does you now know how to find them …). The result should show up in your browser and look like the following:

Our program output in the browser

Our program output in the browser

[Note]Note

If more than one copy of the Simpol Developer Kit IDE are running concurrently then the first window that pops up will not be from the IDE about a request to debug, it will be from the sbngidecaller.exe program asking which copy of the IDE should receive the request to debug. That window looks like this:

Request to select an IDE for debugging

Request to select an IDE for debugging

Select the appropriate entry and then the debugging request message will appear.

Once the program works as it should, we can go back into the settings for the project and add a non-debug target and deactivate the debug target. That way, if we ever need to work on the program again, our debug target is ready to be used. Once you change the target type, don't forget to rebuild the project!

Adding a non-debug target

Adding a non-debug target