SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index

18.1.2 Test SPINS_Webserver

To test SPINS webserver:

This will open up the .HTML file located in:


  sheerpower/sphandlers/wwwroot/index.html 

18.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 18-5 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.

18.1.3.1 Run Web-based Applications on Multiple Ports

To run web-based applications on multiple ports, the following syntax is used:

Example 18-6 Syntax to Specify Multiple Ports

  spins_webserver -port 80 -wwwroot c:\root1 -port 8080 -wwwroot c:\root2 

Each -port nn lets you specify a port. In the above example, we are listening on TWO ports:


  80  and  8080 

18.1.4 Specify Any Root Folder

You can tell the SPINS webserver to use a specific root folder by performing the following command inside the Command Prompt program:

Example 18-7 Specify SPINS webserver root folder

  spins_handler -wwwroot "c:\inetpub\wwwroot" 

Another example would be:


  SPINS_webserver -wwwroot "c:\myplace\stuff\" 

This would mean than an INDEX.HTML file would be in:


  c:\myplace\stuff\index.html 

18.1.5 SPINS Webserver Options

For a list of options (like specifying the wwwroot folder), type the following command inside the Command Prompt program:

Example 18-8 SPINS Webserver Options Command

  C:\sheerpower\sphandlers>  spins_webserver -?

The command will return the following options (subject to change):


  C:\Documents and Settings\User>c:\sheerpower\sphandlers\spins_webserver -? 
  SheerPower InterNet Services Web Server SPINS_WEBSERVER V00.00.060 
  Copyright (c) 2005 Touch Technologies, Inc. - Sat, 17 Sep 2005 19:05:23 
 
  spins_webserver [-option value] [-nextoption value] ... 
     -? or -help                FOR this display 
     -ipaddr xxx.xxx.xxx.xxx    TO specify AP address to listen on 
     -port  ##                  TO specify port to listen on 
     -https ##                  TO specify port to listen on 
     -cafile filespec           FOR Certificate Authority File 
     -certfile filespec         FOR Certificate File 
     -keyfile filespec          FOR Private Key File (default = certfile) 
     -keypass password          FOR Private Key File Password 
     -recvbuf_def ###           TO specify receive buffersize 
     -recvbuf_max ###           TO specify MAXIMUM receive buffersize 
     -sendbuf_def ###           TO specify send buffersize 
     -threads ##                TO specify number of threads to use 
     -virtual hostname pathname TO specify a virtual host and wwwroot 
     -wwwroot pathname          TO specify the wwwroot directory 
     -flags [NOEXCLUSIVE][:DISPLAY_GET][:DISPLAY_PUT] 
            [:DISPLAY_RECV][:STATUS_CONN][:SSL_ERRORS] 
            [:DEBUG][:MISC_DEBUG] 

-port ## and -https ##

Any parameters before a -port or -https will become the global defaults.

Those parameters after the -port or -https will be specific to that port.


Chapter 19
Writing Network Applications and Accessing Devices

SheerPower 4GL includes a number of network-based extensions for accessing data from webpages and sending email.

19.1 Accessing Data from Webpages

FORMAT:


  open ch #num: name 'http://url' 

EXAMPLE:

Example 19-1 Accessing data from webpages

  open #1: name 'http://www.ttinet.com/sheerpower/sample.txt' 
  for count = 1 to 100 
    line input #1, eof eof?: rec$ 
    if eof? then exit for
    print count; tab(10); rec$ 
  next count 
  close #1 
  end

PURPOSE:

To access raw HTML data from anywhere across the Internet.

DESCRIPTION:

The html:// file open option allows programs complete access to raw HTML data. This data can then be used to do things like get stock quotes, read news headlines, and fetch data from SheerPower handlers. For more see Section 19.3, Webserver CGI Interface.

19.2 Sending Email

FORMAT:


  email$ = 'mailto://'       + sendto$       + 
            '?subject='      + subject$      + 
            '&mailfrom='     + mailfrom$     + 
            '&replyto='      + replyto$      + 
            '&friendlyname=' + friendlyname$ + 
            '&cc='           + cc$           + 
            '&server='       + servername$   + 
            '&username='     + username$     + 
            '&password='     + password$     + 
            '&mime_type=html' 
            
  open file email_ch: name email$, access output 
  print #email_ch: 'Text of email.' 
  print #email_ch: 'More text of email.' 
  print #email_ch: 'End of email.' 
  close #email_ch 
  
Where: 
 
  sendto$        = email recipient 
  subject$       = subject line 
  mailfrom$      = who this email will claim it is from 
  replyto$       = the "reply" email address if different from the "mailfrom$" address 
  friendlyname$  = the display name seen by the recipient (i.e. From: "Support" <support@ttinet.com>) 
  cc$            = recipient to be copied on the email 
  servername$    = SMTP server that handles outgoing emails 
  username$      = SMTP server username (if outgoing authentication is required) 
  password$      = SMTP server password (if outgoing authentication is required) 
  mime_type=html = Defines the mime type of the email to allow sending HTML formatted emails 

EXAMPLE:

Example 19-2 Sending Email

  mailform$ = '<form>' 
  mailform$ = mailform$ + 'From: <input type=text name=from ' + 
    'value="Sender email address"><br><br>' 
  mailform$ = mailform$ + 'Reply To: <input type=text name=reply ' + 
    'value="Reply To email address"><br><br>' 
  mailform$ = mailform$ + 'Friendly Name: <input type=text name=display ' + 
    'value="Friendly (display) Name"><br><br>' 
  mailform$ = mailform$ + 'To: <input type=text name=to ' + 
    'value="Recipient email address"><br><br>' 
  mailform$ = mailform$ + 'Server: <input type=text name=server ' + 
    'value="SMTP server name"><br><br>' 
  mailform$ = mailform$ + 'Subject: <input type=text name=subject ' + 
   'value="Subject line"><br><br>' 
  mailform$ = mailform$ + 'Text: <br><textarea name=body rows=5 cols=60>' 
  mailform$ = mailform$ + 'Type in your text here.</textarea><br><br>' 
  mailform$ = mailform$ + '<input type=submit name=submit value="Send Email">' 
  mailform$ = mailform$ + '<input type=submit name=exit value="Cancel">' 
  mailform$ = mailform$ + '</form>' 
  line input dialogbox mailform$: data$ 
  
  for item = 1 to pieces(data$, chr$(26)) 
    z0$    = piece$(data$, item, chr$(26)) 
    name$  = element$(z0$, 1, '=') 
    value$ = element$(z0$, 2, '=') 
    
  select case name$ 
    case 'from' 
      mailfrom$ = value$ 
    case 'reply' 
      replyto$ = value$ 
    case 'display' 
      friendlyname$ = value$ 
    case 'to' 
      sendto$ = value$ 
    case 'server' 
      servername$ = value$ 
    case 'body' 
      text$ = value$ 
    case 'subject' 
      subject$ = value$ 
    case else
  end select
  next item                
  
  email$ = 'mailto://' + sendto$ + '?subject=' + subject$ +
           '&mailfrom=' + mailfrom$ + '&replyto=' + replyto$ + 
           '&friendlyname=' + friendlyname$ + '&server=' + servername$ + 
           '&wait'
                   
  message 'Sending...' 
  open #1: name email$, access output 
    print #1: text$ 
  close #1 
  message 'Sent!' 
end


Previous Next Contents Index