Documentation
Table of Contents
In the previous chapter, we built our first basic program in SIMPOL and learned how to use the IDE to do various tasks. In this chapter, we will take that project and convert it into a web server application to output the same information to a web browser.
As a first step, we can save our project from the first chapter as a new project. To do so, open the first project in the IDE and then select the item from the menu.

Saving the project with a different name
Then give the new project the name learn02 and select the
tutorial directory as the place to store it. This will create a new
project called learn02 with a main source file called learn02.sma.
Now start modifying the source code. Add a cgicall cgi
parameter inside the parentheses of the main() function. Then add the include statement
at the top as shown below and press Ctrl+S to save the
document. The result should look something like the following picture:

Adding an include statement
Note that the IDE has added a document as a child to the main document of the project but that the icon for the document has a red X through it. This is because at this point the project does not have any idea where to look for the include file. To fix this, let's open the Project Settings window again and switch to the tab.

Adding an include path
Now click the button on the left side of the window and select the
include directory that is directly below the root of the Simpol Professional
installation directory. When you return, the window should look like the one below:

The include path has been added
After clicking on the icon that previously was marked with an X is now back to normal.

The icon now appears normally
Now double-click the included file and copy the constant value sHTML_HEADER to the clipboard
so that you can paste it into the main program file. The constant value can be used as long as it has been defined
prior to it's being used. Since the SIMPOL compiler is a single-pass compiler, that means that the file containing
the constant needs to be included at the beginning of the program.

Opening the included file
At this point we need to add the code that outputs the HTML page to the browser. Generally the second parameter to
the output() method of the cgicall type will be set to 1, since currently most
protocols require single-byte characters. The first thing that needs to be output is the header (unless you are using
cookies, then they have to be first). After that the normal HTML code is output.

Adding the code to output the header
Now complete the code as shown in the following picture. The final argument following the end function
statement is the empty string. This is because if it is not set to the empty string, the string representation of the
value .nul will also be returned at the end of the HTML page.

The complete program code for our second program


