Sheerpower®
A Guide to the Sheerpower Language


Previous Contents Index

H.9 HELP

Table H-12 Help Menu
Function Description
SheerPower SPDEV Help Opens a local browser window containing links to the online Sheerpower documentation and downloadable .PDF version.
Check for Updates Checks if you are running the latest version of Sheerpower.
Enter License Information Opens the Enter License Key dialog window. Use the free license key information provided with your Sheerpower installation.
Ordering Information Opens a new browser window containing Sheerpower Support purchase options.
SheerPower 4GL Home Page Opens the Sheerpower website in a new browser window.
About SPDEV Displays the current version and build number of SPDEV.


Appendix I
Developing Professional Applications with Sheerpower

I.1 Application Example

The purpose of this tutorial is to illustrate the special keystrokes and other editing features of Sheerpower Rapid Development Environment (SPDEV) that enable a programmer to easily and quickly create professionally formatted programs.

80% of the cost of coding is maintenance (versus writing new code), so making maintenance programming more efficient is very important.

The program used in this tutorial already exists in /sheerpower/sphandlers/scripts/sp4gl/ as send_email.spsrc. For this tutorial you will re-create the program in a new program file. The specific features in SPDEV that are highlighted are:

To illustrate how a well laid out program containing program headers and routine headers can benefit you and possibly future programmers tasked with maintaining and updating the code in this program, below is the tutorial example program without any comments, headers or routines:


servername$ = '' 
if servername$ = '' then 
  message error: 'Please change the "servername" in the source code ' + 
                 'to be your SMTP server name.' 
  stop 
end if 
email_image$ = 'c:\sheerpower\samples\emailicon.jpg' 
 
do 
  email_form$ = '<sheerpower color=#ffaaaa persist>' 
  email_form$ = email_form$ + '<form><title>Send Email</title>' 
  email_form$ = email_form$ + '<img src="' + email_image$ + '"><p>' 
  
  email_form$ = email_form$ + '<table align=center>' 
  email_form$ = email_form$ + '<tr><td align=left><b>From:</b> ' 
  email_form$ = email_form$ + '<td><input type=text name=from ' + 
    'value="Enter sender email address here"></tr>' 
  email_form$ = email_form$ + '<tr><td align=left><b>To:</b> ' 
  email_form$ = email_form$ + '<td><input type=text name=to ' + 
    'value="Enter recipient email address here"></tr>' 
  email_form$ = email_form$ + '<tr><td align=left><b>Subject:</b> ' 
  email_form$ = email_form$ + '<td><input type=text name=subject ' + 
    'value="Type in a subject here"></tr>' 
  email_form$ = email_form$ + '<tr><td align=left><b>Body:</b> ' 
  email_form$ = email_form$ + '<td><br><textarea name=body rows=10 cols=30>' + 
    'Enter the body of the email here</textarea><p>' 
  email_form$ = email_form$ + '</textarea><p></tr></table>' 
  email_form$ = email_form$ + '</table>' 
  
  email_form$ = email_form$ + '<p><center>' + 
                '<input type=submit name=submit value="Send Email">' 
  email_form$ = email_form$ + '<input type=submit name=exit value="Quit Email">' 
  email_form$ = email_form$ + '</center></form>' 
  line input dialogbox email_form$: info$ 
  
  if _exit then exit do 
  for item = 1 to pieces(info$, chr$(26)) 
    z0$    = piece$(info$, item, chr$(26)) 
    name$  = element$(z0$, 1, '=') 
    value$ = element$(z0$, 2, '=') 
    
  select case name$ 
     case 'from' 
      mailfrom$ = value$ 
    case 'to' 
      sendto$ = value$ 
    case 'body' 
      text$ = value$ 
    case 'subject' 
      subject$ = value$ 
    case else 
  end select 
  next item    
  if pos(mailfrom$,'@') = 0 or pos(sendto$,'@') = 0 then repeat do 
  
  email$ = 'mailto://'   + sendto$   + 
            '?subject='  + subject$  + 
            '&mailfrom=' + mailfrom$ + 
            '&server='   + servername$ 
  open #1: name email$, access output 
    print #1: wrap$(text$,1,72) 
  close #1 
loop 
stop 

And here is the same program, but with code comments, headers and routines:


!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! Program: Send Email Tutorial 
! System : 
! Author : SNI 
! Company: TTI 
! Date   : November 12, 2015 
! Purpose: To send basic emails using Sheerpower 
! 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
!         I n i t i a l i z a t i o n 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
servername$ = ''  // Change to be *your* SMTP server IP or domain name 
 
if servername$ = '' then 
  message error: 'Please change the "servername" in the source code ' + 
                 'to be your SMTP server name.' 
  stop 
end if 
 
// if your Sheerpower installation is in a different folder then change 
// the file path for this image file to point to the correct location 
email_image$ = 'c:\sheerpower\samples\emailicon.jpg' 
 
 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
!         M a i n   l o g i c   a r e a 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
do 
  show_email_form 
  if _exit then exit do 
  parse_results 
  if pos(mailfrom$,'@') = 0 or pos(sendto$,'@') = 0 then repeat do 
  send_email 
loop 
stop 
 
 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
!         R o u t i n e s 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! s h o w _ e m a i l _ f o r m 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! 
! Brief description: 
!   Create the form containing the from, to, subject 
!   and body fields. 
! 
! Expected on entry: 
!   email_image$ = the location and name of the image to insert 
!                  into the form. 
! 
! Locals used: 
! 
! 
! Results on exit: 
!   info$       = chr$(26) separated line of data results entered 
!                 into the form input fields. 
! 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
routine show_email_form 
  email_form$ = '<sheerpower color=#ffaaaa persist>' 
  email_form$ = email_form$ + '<form><literal><title>Send Email</title><endliteral>' 
  email_form$ = email_form$ + '<img src="' + email_image$ + '"><p>' 
  
  email_form_table 
  
  email_form$ = email_form$ + '<p><center>' + 
                '<input type=submit name=submit value="Send Email">' 
  email_form$ = email_form$ + '<input type=submit name=exit value="Quit Email">' 
  email_form$ = email_form$ + '</center></form>' 
  line input dialogbox email_form$: info$ 
end routine 
 
 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! e m a i l _ f o r m _ t a b l e 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! 
! Brief description: 
!   The table inside the form is created. 
! 
! Expected on entry: 
!   email_form$ = code to create the form 
! 
! Locals used: 
! 
! 
! Results on exit: 
!   The table inside the form is created. 
!   email_form$ now includes the table 
! 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
routine email_form_table 
  email_form$ = email_form$ + '<table align=center>' 
  email_form$ = email_form$ + '<tr><td align=left><b>From:</b> ' 
  email_form$ = email_form$ + '<td><input type=text name=from ' + 
    'value="Enter sender email address here"></tr>' 
  email_form$ = email_form$ + '<tr><td align=left><b>To:</b> ' 
  email_form$ = email_form$ + '<td><input type=text name=to ' + 
    'value="Enter recipient email address here"></tr>' 
  email_form$ = email_form$ + '<tr><td align=left><b>Subject:</b> ' 
  email_form$ = email_form$ + '<td><input type=text name=subject ' + 
    'value="Type in a subject here"></tr>' 
  email_form$ = email_form$ + '<tr><td align=left><b>Body:</b> ' 
  email_form$ = email_form$ + '<td><br><textarea name=body rows=10 cols=30>' + 
    'Enter the body of the email here</textarea><p>' 
  email_form$ = email_form$ + '</textarea><p></tr></table>' 
  email_form$ = email_form$ + '</table>' 
end routine 
 
 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! p a r s e _ r e s u l t s 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! 
! Brief description: 
!   To parse the results of the form field entries and store 
!   them into variables. 
! 
! Expected on entry: 
!   info$  = chr$(26) separated line of data results entered 
!                 into the form input fields. 
! 
! Locals used: 
!   name$  = stores the "name" of each input field inside the form. 
!   value$ = stores the parsed data contained in info$ for each 
!            piece of data given by the user into the form input fields. 
! 
! Results on exit: 
!   mailfrom$ = the value of the sender's email address 
!   sendto$   = the value of the recipient's email address 
!   text$     = the body text of the email 
!   subject$  = the subject line for the email 
! 
!   The data entered into the form is parsed and stored into 
!   variables. 
! 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
routine parse_results 
  for item = 1 to pieces(info$, chr$(26)) 
    z0$    = piece$(info$, item, chr$(26)) 
    name$  = element$(z0$, 1, '=') 
    value$ = element$(z0$, 2, '=') 
    
  select case name$ 
     case 'from' 
      mailfrom$ = value$ 
    case 'to' 
      sendto$ = value$ 
    case 'body' 
      text$ = value$ 
    case 'subject' 
      subject$ = value$ 
    case else 
  end select 
  next item    
end routine 
 
 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! s e n d _ e m a i l 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! 
! Brief description: 
!   We store the email data into the variable that contains the 
!   email sending command line, and send the email. 
! 
! Expected on entry: 
!   mailfrom$   = the value of the sender's email address 
!   sendto$     = the value of the recipient's email address 
!   text$       = the body text of the email 
!   subject$    = the subject line for the email 
!   servername$ = the name of the SMTP server 
! 
! Locals used: 
! 
! 
! Results on exit: 
!   email$ = stores the command line that contains the SMTP server name, 
!            'to' email address, 'from' email address and the subject 
!            line of the email.              
! 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
routine send_email 
  email$ = 'mailto://'   + sendto$   + 
            '?subject='  + subject$  + 
            '&mailfrom=' + mailfrom$ + 
            '&server='   + servername$ 
  open #1: name email$, access output 
    print #1: wrap$(text$,1,72) 
  close #1 
end routine 
 
end 

The difference between the two versions of this program is clear. The version with comments and routine headers will help any future programmer (including yourself) maintain and update the program much more efficiently.

I.2 Creating a Professional Program File

There are two ways to create a new program file with a program template inserted into it:

Next are the steps to create a new .SPSRC program file with a program template in it at the time the file is created.


Previous Next Contents Index