Sheerpower®
A Guide to the Sheerpower Language


Previous Contents Index

Next we will insert the second routine by first creating the routine header for it.

I.4.1 Using GOLD/R to Make Subroutines

Often routines can get to be too long and complicated. Sheerpower makes it easy to make subroutines from within a routine. Just highlight the code you want to move into a subroutine and press [GOLD][R]. You will be prompted to type in a name for the subroutine. Type in the name and press [OK]. Sheerpower will move the highlighted code into a new subroutine below the original routine instantly.

In the news.spsrc example, we will illustrate how this is done.

Inside the news.spsrc program file, highlight the following section of Sheerpower code near the bottom of the program:


    // first add in the  http://www.cnn.com  to any anchors 
    dbox$ = replace$(dbox$, '<a href="==<a href="http://www.cnn.com/',',', '==') 
    // now finish off the input form with a single "submit" button 
    dbox$ = dbox$ + '</h2><input type=submit></form>' 

Now press [GOLD][R]. The New Routine dialog box will appear. Type the name of the subroutine being created as complete_form.

You can leave the Optional Parameters fields blank for the purpose of this tutorial.

Click on [OK]. Sheerpower will take the highlighted code from the original routine, and create a new routine below the first one containing the highlighted code.

Sheerpower will also insert the CALL for the subroutine inside the original routine.

The completed routine header for complete_form is as follows:


!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! c o m p l e t e _ f o r m 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! 
! Brief description: 
!   Add the CNN URL to anchors and complete the form with the submit 
!   button. 
! 
! Expected on entry: 
!   dbox$ = stores the code to create the dialogbox 
! 
! Locals used: 
!   none 
! 
! Results on exit: 
!   Any anchors are now complete with the CNN URL and the form 
!   is completed. 
! 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

I.4.2 Running the Example Program

RUN this program by clicking on the Run icon in the SPDEV toolbar---the running man.

The program goes out to www.cnn.com and grabs the latest headline for the top news story, then displays it in a form window with a clickable link to the complete story.

I.5 Routine Definitions

To make it easier to locate routines and find out what they do inside large programs, SPDEV has two specially mapped keys to assist:

F12: Show definition

F11: Go to definition

I.5.1 F12 - Show definition

The F12 key displays the routine header information inside a new window. This feature especially benefits maintenance programmers.

You can place your cursor on the reference to any routine name inside a program, press [F12] and a new window will appear containing the routine definition (header information).

Inside the example program news.spsrc place your cursor on the reference to the routine get_headline in the Main logic area.


!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
!         M a i n   l o g i c   a r e a 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
news_ch = _channel 
open #news_ch: name 'http://www.cnn.com' 
get_headline    //<--- place your cursor on this routine reference 
 
stop 

Now press the [F12] key. The following new window will appear:

The special F12 keystroke allows you to find the details about any routine in a program without having to go to the actual routine.

I.5.2 F11 - Go to definition

The F11 key takes you directly to a routine when you place your cursor on the reference to that routine.

Inside the example program news.spsrc place your cursor on the reference to the routine get_headline in the Main logic area.


!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
!         M a i n   l o g i c   a r e a 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
news_ch = _channel 
open #news_ch: name 'http://www.cnn.com' 
get_headline    //<--- place your cursor on this routine reference 
 
stop 

Now press the [F11] key. You will automatically be taken to the start of the get_headline routine.

To get back to where you were simply press GOLD/B. See Appendix F, Keystrokes for Sheerpower Rapid Development Environment for more details on all the special programming keystrokes built into the Sheerpower Rapid Development Environment.

I.6 Using GOLD/O to Organize Routines

Routines can become logically out of order as a program is being written, making it hard to follow program logic and hard to find a given routine.

In SPDEV, the GOLD/O keystroke lets you automatically order your routines in either calling order or alphabetical order.

Inside the example program news.spsrc place your cursor anywhere and press the GOLD key ([Esc]), let go, then press the O key. The Organize Code dialog box will appear.

The routines in news.spsrc are currently organized in calling order. Select Alphabetically.

Routine complete_form will now be first in the program, and get_headline will be last. Press GOLD/O again and choose in calling order. Then click on [OK]. The routines will now be organized in their calling order.

See Appendix F, Keystrokes for Sheerpower Rapid Development Environment for more details on all the special programming keystrokes built into the Sheerpower Rapid Development Environment.


Appendix J
Sample Sheerpower Programs Included With Installation

The following programs have been included in the distribution of Sheerpower. They can be found in the Samples folder inside your Sheerpower folder: \sheerpower\samples folder. (The default install location for Sheerpower is c:\sheerpower.)

We encourage you to:

Table J-1 Program File List and Description
Program Name Description
CDPLAYER.SPSRC This program illustrates Sheerpower making Windows API calls. In this case it is controlling the computer's CD player.
CLIENT_SCAN.SPSRC This program scans through a database of clients looking for names similar to what is being searched for.
CQUERY.SPSRC Shows how to do a simple query on a database using INPUT DIALOGBOX to display the form, allowing for key lookups and updating data fields.
DDETEST.SPSRC Have Sheerpower control an Excel spreadsheet!
DISPLAY_AND_UPDATE.SPSRC Display and update information stored in a database.
EVAL.SPSRC In this program, the user enters a complex mathematical expression. Sheerpower evaluates the expression and returns the solution.
KBTUTOR.SPSRC This is a complete program to develop keyboard skills and touch typing methods. It tracks accuracy and skill levels providing instant feedback to the user. Try it and find your keyboard skill level!
MAKE_HTML.SPSRC This program generates simple HTML and opens up a new browser window upon completion.
MULTI_TABLE_DIALOGBOX_STATEMENT.SPSRC This sample program illustrates accessing multiple tables in a database, then putting the data into a form using INPUT DIALOGBOX. This program can be found in multi-table.zip.
MULTI_TABLE_HTML_STATEMENT.SPSRC This program illustrates how to access data from multiple tables in a database, then printing the data to an .HTML file... then opens the HTML file using PASS URL. This program can be found in multi-table.zip.
MULTI_TABLE_SCREEN_STATEMENT.SPSRC This program shows how to access multiple tables in a database, then print out the data to the screen. This program can be found in multi-table.zip.
PLAY_SOUND This program illustrates Sheerpower playing .wav sound files using the MEDIA statement.
PRECISION.SPSRC An example of Sheerpower's perfect precision. Try this with your current programming language.
QUIZ.SPSRC A simple quiz program showcasing Sheerpower's strengths in dynamic form generation and database access. Includes feedback response to both correct and incorrect responses.
SEND_EMAIL.SPSRC This program generates a form that allows the user to create and send an email.
SET_ICON.SPSRC This program shows you how to dynamically change the taskbar icon.
SIEVE.SPSRC This is a benchmark program that generates a count of prime numbers.
STOCKQUOTE.SPSRC Enter a stock symbol or a list of stock symbols. Sheerpower will return the current stock price quote for each symbol entered.


Previous Next Contents Index