Previous | Contents | Index |
To start Sheerpower Rapid Development Environment (SPDEV), double click the Sheerpower shortcut icon located on your desktop---a circle with a lightning bolt through it.
To create a new program in SPDEV, click once on the New icon in the toolbar---a white paper with one corner folded.
Name your new program file send_email_tutorial. If you have just installed Sheerpower, the default file save location will be in the main Sheerpower folder (c:\sheerpower) and the default file type will be .SPSRC. The full program name will be send_email_tutorial.spsrc. You can browse to save the file to any location in your computer that you want. When you are done naming the file and selecting the location to save it in, click on [SAVE] inside the Name New File... dialog box.
The Get Program info dialog box will open, prompting you to enter your name, company name and program name. The program name will already be filled in for you. These fields are optional.
If you enter in your name and company name, they will be saved in SPDEV and will be the default used each time a program template is generated. When you click on [OK], a program template will automatically be inserted into your new program file. If you click on the [Cancel] button, no program template is generated and a blank file will open in SPDEV.
For this tutorial, enter in your name and company name if applicable, then click on [OK].
Note: You can change your name and/or company name configured in SPDEV at anytime by clicking on Options in the SPDEV toolbar, then selecting Change System Settings. The fields to be changed are at the top of the Settings dialog box.
The new file will open with a Program Template inserted into it.
Example I-1 Program Template |
---|
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Program: send_email_tutorial.spsrc ! System : . ! Author : Your Name ! Company: Your Company Name ! Date : November 12, 2015 ! Purpose: ! !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! I n i t i a l i z a t i o n !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! M a i n l o g i c a r e a !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% stop !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! R o u t i n e s !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end |
The previous section illustrated how you can easily generate a program template in SPDEV at the same time you create a new Sheerpower program file. Additionally, a program template can also be created instantly inside any file open in SPDEV by using the specially mapped GOLD/P keystroke.
The GOLD Key referred to in this section is a special key used to create many of the specialized keystrokes within SPDEV. The [Esc] (escape key - top left corner of the keyboard) is a GOLD key in SPDEV.
To use the GOLD key, press the GOLD key ([Esc]), let go, then continue with the rest of the keystroke to execute the function.
When you use GOLD/P keystroke to generate a program template inside a file, the Get Program Info dialog box will open allowing you to enter or change the program name, your name and company name. Click on [OK] to generate the template, or [Cancel] to cancel creating the template.
The current Date is entered into the program template heading automatically, along with the Author and Company names. You can type in a System name if it is applicable to your program.
By default the cursor will be positioned in the top section of the template beside Purpose:. This is where you describe the purpose of your new program here. The purpose of send_email_tutorial.spsrc is: To send basic emails using Sheerpower.
Example I-2 Program Template: Header |
---|
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Program: Send Email Tutorial ! System : ! Author : SNI ! Company: TTI ! Date : November 12, 2015 ! Purpose: To send basic emails using Sheerpower ! !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
The next section in the program template is Initialization. This section is used to initialize variables used in the program. Copy and paste the following Sheerpower program code underneath the Initialization heading.
Example I-3 Program Template: Initialization |
---|
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' |
The next section is the Main logic area. This is where you outline the main logic of your program. Stop is automatically inserted at the bottom of this section. It tells Sheerpower that the program has ended.
Copy and paste the following code underneath the Main logic area heading above the word stop.
Example I-4 Program Template: Main logic area |
---|
do 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$ if _exit then exit do parse_results if pos(mailfrom$,'@') = 0 or pos(sendto$,'@') = 0 then repeat do send_email loop |
Below the Main logic area you will see the program
template heading Routines. Below this heading is where
all the routines in your program will go. In the next section you will
learn how to create the routine templates to work with
inside the program template.
I.4 Routine Template
Programs are made up of ROUTINES. Each routine has its own heading with details on what the purpose of the routine is, and how it works. Creating routines with clear and well detailed routine headers helps to maintain the code, debug and make new coding changes.
Place your cursor underneath the Routines heading. Press the [GOLD] key ([Esc]), and then let go of it. Then press [R]. You will see the following prompt:
The first routine in our tutorial example as defined in the Main Logic Area is Type clear_values inside the empty field beside Routine Name:.
Note: In Sheerpower, all routine names must contain at least one underscore (_). |
The Optional Parameters section contains the following fields:
Parameter | Description |
---|---|
With: | parameters being passed into the routine. |
Returning: | parameters returned as a result of running the routine. |
Private: | variables that can only be accessed from inside this routine. |
You can leave the Optional Parameters fields blank for the purpose of this tutorial.
See Section 3.5, Passing Optional Parameters to Routines for more on passing parameters in Sheerpower. |
Click on [OK]. The ROUTINE HEADER TEMPLATE will appear.
Example I-5 Routine Header Template |
---|
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! ! Brief description: ! ! ! Expected on entry: ! ! ! Locals used: ! ! ! Results on exit: ! ! !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% routine get_headline end routine |
There are four fields to complete inside the Routine Header Template:
Here is the completed routine header for this routine:
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! c l e a r _ v a l u e s !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! ! Brief description: ! Clear formatting values ! ! Expected on entry: none ! None ! ! Locals used: ! ! Results on exit: ! Formatting values are cleared ! ! !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
Copy and paste the following Sheerpower code into the clear_values routine on a blank line in between routine clear_values and the end routine statement. The first line of code is indented two spaces under the routine statement with the rest of the code indented accordingly below.
routine clear_values sym$ = '' price$ = '0' pchange$ = '+0' lasttime$ = '' lastdate$ = '' volume$ = '0' end routine |
This is the first routine of the program completed. The program will now look like this:
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Program: Stock Quote ! System : Samples ! Author : Daniel Esbensen ! Company: Touch Technologies, Inc. ! Date : October 11, 2001 ! Purpose: Given a stock symbol display a quote ! !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! I n i t i a l i z a t i o n !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% qurl$ = "http://finance.yahoo.com/d/quotes.csv?s=" qurl2$= "&f=sl1c1t1d1v&e=.csv" bottom_part$ = '<p><input type=submit value=Submit name=submit>' + '<input type=submit value=Exit name=exit>' + '</form>' !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! M a i n l o g i c a r e a !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear_values found? = true dbox$ = '<sheerpower autosubmit=3000 persist><form>' dbox$ = dbox$ + '<center><h2>Stock Symbol Lookup</h2></center><p>' dbox$ = dbox$ + 'Symbols (comma separated) <input name=symbol submit value="' + symbol$ + '">' dbox$ = dbox$ +'<p>' + bottom_part$ + '</form>' do line input dialogbox dbox$: ans$ if _exit then exit do z0$ = element$(ans$, 1, chr$(26)) // just the first value pair symbol$ = element$(z0$, 2, '=') // grab the stock symbol(s) if symbol$ = '' then repeat do get_quote loop stop !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! R o u t i n e s !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! c l e a r _ v a l u e s !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! ! Brief description: ! Clear formatting values ! ! Expected on entry: none ! None ! ! Locals used: ! ! Results on exit: ! Formatting values are cleared ! !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% routine clear_values sym$ = '' price$ = '0' pchange$ = '+0' lasttime$ = '' lastdate$ = '' volume$ = '0' end routine |
Previous | Next | Contents | Index |