// This test program shows how to use SheerPower 4GL as a POWERFUL web scripting language. // // The tag <<%spscript>> tells SheerPower that the script area that follows is to be output // to the browser. The script area ends when you use a <%spscript>> or a <<%spcode>> // tag all by itself on a line. // // While in a script area, text inside of << >> is treated as embedded SheerPower code. // If the embedded code consists of an expression, then the expression is evaluated // and the results are sent to the browser. If the embedded code starts with // a $ (dollar sign) then what follows the $ is treated as a CGI symbol lookup and // the result of that lookup is sent to the browser. // // For example, to send to the browser html of the value of CITY -- where CITY was // received from a browser form submit: // // The city was: <<$CITY>> // ** Note that CASE MATTERS in CGI symbol names ** // // If a text line begins with just the two characters of << then all following lines are // treated as a SheerPower code area. An ending line consisting of just two >> characters ends the // code area. // // You can also use the <<%spcode>> tag on a line all by itself to start a SheerPower code area. The // area ends when you use a <%spcode>> or a <<%spscript>> tag all by itself on a line. // // When in a SheerPower code area, printing to channel zero [just a "normal" print statement] // causes the printed text to be sent to the browser. For example, when in // a SheerPower code area, to send HTML to the browser that displays a // client's city in bold: // print ''; client(city); '' // // The function GETSYMBOL$() is used to get the CGI symbol value from the webserver. // For example, to get the value of the symbol 'password' and store it into the variable mypassword$ : // mypassword$ = getsymbol$('password') // If the symbol does not exist, then a null string is returned. // // Standard CGI environment symbols must be prefixed with "env:" such as: // myip$ = getsymbol$('env:REMOTE_ADDR') // // SheerPower scripting programs must be located in scripts\sp4gl\ // // By default this location is c:\sheerpower\sphandlers\scripts\sp4gl\ // // To invoke the script with your browser: // // o start the SPINS_WEBSERVER if not yet started by: // // c:> c:\sheerpower\sphandlers\spins_webserver.exe // // o Give the URL of your server to the browser // // http://localhost/test.spsrc (or replace LOCALHOST with the domain of your server) // // ** Note: SPRUN files are also supported ** // // If you wish to have a script hang around for a bit for HIGH PERFORMANCE -- then use // the <<%persist>> and <%persist>> tags. // // Place the <<%persist>> tag at the beginning of your main logic area, and the <%persist>> at the end // of your main logic area. In addition, find any code that you want to run just once per persistance // and surround that code with <<%once>> and <%once>>. Good candidates are data structures (tables) // that can be opened once and then left open. Also good candidates are any constants that you // might want statically initialized before your main logic starts. // // The PERSISTANT versions will automatically go away if not used very much. <<%persist>> <<%spscript>>
| City | ID | Full name
<| < | < | < | < |
|---|
<%spscript>> end routine !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! d i s p l a y _ f o r m !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! ! Brief description: ! Display the input form asking for a city to search for. ! ! Expected on entry: ! nothing ! ! Locals used: ! ! ! Results on exit: ! The form is submitted back to ourselves so we can process it ! !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% routine display_form ask system: program this_program$ this_program$ = fileinfo$(this_program$, 'name,type') <<%spscript>>
(Request was from IP <<$env:REMOTE_ADDR>>)
<%spscript>>
end routine
end