Sheerpower®
A Guide to the Sheerpower Language


Previous Contents Index


Appendix K
Generation Language

Table K-1 What is a 4GL?
GL Description
GL "Generation Language"
1GL No one uses this anymore to program in. To program in 1GL a person would be physically at a computer with a bunch of switches literally programming into the computer 1's and 0's by pressing the switches manually.
2GL Also known as "Machine Code", "Compute Instructions", and "Assembler". A 2GL language tells the computer precisely what to do. Instructions are given to the actual CPU.
3GL Java, Cobol, Basic, C++ are all 3GL languages. The instructions given to the computer are more generalized. More words are used than instructions. The type of computer or memory location are not given using a 3GL language.

Compiling and linking converts the code to 2GL which then converts to the 1GL to run the program.

4GL Is not a precise programming language. A 4GL programming language makes assumptions on the command given. A 4GL programming language is faster, but the results very generalized.

"Sure is easy to do things, but I can't do anything with it!"

If a programmer wants to override the assumption and get a specific result, they need to use a 3GL language.

Sheerpower is both a 3GL and a 4GL---that one is of the reasons why Sheerpower is so powerful!


Appendix L
Troubleshooting the CGI Interface

L.1 CGI Troubleshooting Checklist

Sheerpower applications can easily be "web-enabled" through its simple CGI Interface. The CGI interface works with Sheerpower's SPINS webserver. SPINS_webserver.exe is included in the download of Sheerpower. It is automatically installed in:


  \sheerpower\sphandlers\

See Chapter 17, Sheerpower Internet Services (SPINS) Webserver for the complete chapter on SPINS webserver.

The following is a checklist to go through if you experience problems with the Sheerpower CGI Interface and SPINS webserver.

L.1.1 Stop Microsoft IIS Webserver

If the Microsoft IIS webserver is installed and running on the system, it must be stopped or a different port specified for either webserver to run SPINS for the first time. Before running SPINS webserver for the first time:

L.1.2 Test SPINS_Webserver

To test SPINS webserver:

This will open up the .HTML file located in:


  sheerpower/sphandlers/wwwroot/index.html 

L.1.3 Specify a Different Port Number

To tell the SPINS webserver to use a different port number from the default port 80, start it from the Command Prompt program or with a PASS NOWAIT statement within your program using the following syntax:

Example L-1 Syntax to Change Port Number Used

  spins_webserver -port nn

For example, to change from the default port 80 to port 8080:


  spins_webserver -port 8080

to use port 8080.

Running SPINS and IIS Simultaneously

If you need to utilize some of the IIS facility, you can set the IIS webserver to use port 8080 and the SPINS websever to use port 80 (or the other way around). Both webservers can co-exist this way.

L.2 Testing the CGI Interface

L.2.1 Sheerpower CGI Interface Sample Program

The sample CGI program eval_handler.spsrc is located in:


  c:\sheerpower\sphandler 

The webpage that goes along with the sample program is located in the same folder, and is called cgi.html.

First, using Windows Explorer, double-click on the EVAL_HANDLER.SPSRC file. This runs the EVAL_HANDLER program. This program by default is located in:


  c:\sheerpower\sphandlers\eval_handler.spsrc 

After the EVAL_HANDLER has been started, you can try the FORM below.

After entering an expression, press the ENTER key. To get back to this webpage, click on the browser's BACK button.

Enter an expression, like sin(355/113) and press the ENTER key

L.2.2 How This Form Works

Each time anyone enters an expression to evaluate (like 2+3), their browser sends the data to your SPINS webserver along with a handler name. In this example, the handler name is EVAL. The SPINS websever then passes the data to the EVAL_HANDLER.SPSRC Sheerpower program. The EVAL_HANDLER handles the request, figures out the result, and sends the result back to the SPINS server. The SPINS server then sends the result back to the browser.

L.2.3 How The EVAL_HANDLER Program Works

In order to handle CGI requests, the following steps need to be taken:

L.2.3.1 Open A CGI connection

First we open our CGI connection to the SPINS server:


    handler_name$ = 'cgi://EVAL' 
    open file cgi_ch: name handler_name$ 

In this example, EVAL is the HANDLER NAME. For higher performance, you can run as many copies of this handler as you want. The Sheerpower CGI interface will queue all requests to these handlers that have the form:


    http://www.ttinet.com/scripts/spiis.dll/EVAL    

Next we set up a logic loop to wait for requests, handle timeouts, and process each request:


    do 
      line input #cgi_ch: method$
      if method$ = '' then repeat do 
      .. 
      .. 
    loop    

L.2.3.2 Waiting For Requests

The LINE INPUT waits for a request from the SPINS server. When the LINE INPUT completes, the variable METHOD$ will contain one of three values:

In this program, when there is no request from the SPINS webserver (a timeout), we just go back and try again. In complex applications a program might instead unlock databases, write out statistics, and then go back and try again.

L.2.3.3 Processing A CGI Request

Now that we have a request from the SPINS server, we have to process the request.


  ask #cgi_ch, symbol 'EXPR': value expr$
  if  expr$ = '' then 
    print #cgi_ch: '<h2>Thank you for using the Evaluator!</h2>'
    repeat do 
  end if 
  
  when exception in 
    answer = eval(expr$) 
  use 
    answer = extext$ 
  end when 
  if dtype(answer) <> 1 then answer = str$(answer) 
  print #cgi_ch: '&lt;h2&gt;'; expr$; ' --> '; answer; 
  '&lt;/h2&gt;' 
  ask #cgi_ch, symbol 'env:REMOTE_ADDR': value ipaddr$
  print #cgi_ch: '(Your IP address is '; ipaddr$; ')'

This form returns one form variable---the expression to be evaluated (EXPR). We use the Sheerpower ASK instruction to ask for its value.


  ask #cgi_ch, symbol 'EXPR': value expr$

If they didn't enter any expression, we just tell them "Thank you...". This is done using the PRINT instruction.


    print #cgi_ch: '&lt;h2&gt;Thank you for using the Evaluator!&lt;/h2&gt;'

Using EXPR$, we calculate the ANSWER and PRINT the result back to the SPINS server.


  print #cgi_ch: '&lt;h2&gt;'; expr$; ' --> '; answer; '&lt;/h2&gt;' 

Finally, we ask the SPINS server for the "REMOTE_ADDR". This is the IP address of the requestor. Since "REMOTE_ADDR" is an environmental variable, we must put "env:" in front of the symbol name. Once we get the IP address, we PRINT it to the SPINS server--- which, in turn, sends the data back to the browser.


  ask #cgi_ch, symbol 'env:REMOTE_ADDR': value ipaddr$
  print #cgi_ch: '(Your IP address is '; ipaddr$; ')'


Previous Next Contents Index