SheerPower® 4GL
-- Beyond BASIC --

Professional Application Development Tutorial


FREE !! Download SheerPower 4GL NOW!
Try SheerPower now and compare
to your current software development language!!

Fully functional!
No license needed!
Royalty free distribution!
Less than a 3MB download!

Submit Feedback

Contact Us

SheerPower 4GL Documentation
  • Online Documentation
  • Downloadable/Printable Version
       (.PDF file, approx. 3MB download)

    FAQ

    Getting Started Tutorial

    Application Tutorial

    Sample Programs

  • Optional SheerPower 4GL GOLD Licenses
    available! License Purchase Information

    Why have a
    SheerPower 4GL GOLD License?

    Home

    Developing Professional Applications with SheerPower 4GL

    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 SheerPower Rapid Development Environment, click once on the New icon in the toolbar---a white paper with one corner folded.

    Name your new program file news.spsrc and click on [SAVE]inside the Name New File... dialog box.

    You are now ready to write a professional application in SheerPower.

    Program Template

    A PROGRAM TEMPLATE can be created instantly inside a program file by using the GOLD/P keystroke inside SheerPower Rapid Development Environment (SPDEV).

    The GOLD Key referred to in this section is a special key used to create many of the specialized keystrokes within SPDEV. Both the [Esc] (escape key - top left corner of the keyboard) and the [Num-Lock] (numbers lock key in the numeric keypad) are GOLD keys in SheerPower Rapid Development Environment.

    To use the GOLD key, press either GOLD key ([Esc] or [Num-Lock]), let go, then continue with the rest of the keystroke to complete the function.

    Inside the empty news.spsrc program file window in SPDEV, press the [GOLD] key, let it go, then press the [P] key.

    The very first time you use GOLD/P special keystroke, you will be prompted for the following information in separate dialog boxes:

    The name of the program.

    Your name (the programmer/author's name).

    The company name.

    You can choose to fill in the field inside each dialog box or not. Click on the [OK] button to proceed to each dialog box.

    Note

    The above series of dialog boxes will only appear the first time that you use the GOLD/P keystroke.

    You can change your name, company name and initials at anytime by clicking on Options in the SPDEV toolbar, then selecting Change System Settings.

    Click on [OK] inside the Get Company Name dialog box. The following program template will appear inside the file:

    Example H-1 Program Template

    !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    ! Program: Name of program 
    ! System : 
    ! Author : Your name 
    ! Company: Company name 
    ! Date   : June 30, 2002 
    ! 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 
     
    

    Your cursor will be positioned at the top section of the template beside Purpose:. You can type in the purpose of the program being written here. The purpose of news.spsrc (this example program) is: To present the top news story from CNN.COM.

    SPDEV automatically fills in the name of the program, the author and company names, and the date for you.


    !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    ! Program: news 
    ! System : 
    ! Author : Your name 
    ! Company: Company name 
    ! Date   : June 30, 2002 
    ! Purpose: To present the top news story from CNN.COM 
    ! 
    !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    

    Copy and paste the following SheerPower code underneath the Initialization heading.


    // Note:  From time to time CNN changes its format, so the 
    //        main$  and  end_main$  sometimes have to be changed. 
     
    main$ = '<div class="cnnMainT1Area"' 
    end_main$ = '</div>' 
     
    begin_form$ = '<form>' + 
                  '<h1><font color=green>' + 
                  'Top News from CNN' + 
                  '</font></h1>' + 
                  '<br><h2>' 
    

    Copy and paste the following code underneath the Main logic area heading above the word stop.


    news_ch = _channel 
    open #news_ch: name 'http://www.cnn.com' 
    get_headline 
    

    Now you are ready to write the routines that create news. spsrc.

    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 a Routine Header Template

    Place your cursor underneath the Routines heading. Press the [GOLD] key (either [Esc] or [Num-Lock]), and let go. Then press [R]. You will see the following prompt:

    Type get_headline inside the empty field:

    Note

    All routine names must contain at least one underscore (_).

    Click on [OK]. The ROUTINE HEADER TEMPLATE will appear.

    Example H-2 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:

    • Brief description - describe the purpose of the routine.
    • Expected on entry - list variable names and the data they store that are coming into the routine (already defined).
    • Locals used - list any variables defined in this routine only and the data they store.
    • Results on exit - list any variables defined in this routine that will be used elsewhere in the program. Include what the result of the routine will be on exit.

    Here is the completed routine header for this routine:


    !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    ! g e t _ h e a d l i n e 
    !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    ! 
    ! Brief description: 
    !   Go out to www.cnn.com and extract the headline of the top 
    !   news story. 
    ! 
    ! Expected on entry: 
    !   main$       = the starting point of the headline 
    !   begin_form$ = the top HTML code for the dialogbox form 
    !   end_main$   = the end point of the headline 
    ! 
    ! Locals used: 
    !   text$  = the HTML code on the CNN website 
    !   crlf$  = contains the character line feeds 
    !   state$ = 
    ! 
    ! Results on exit: 
    !   dbox$  = stores the code to create the dialogbox 
    ! 
    !   The headline is found and the form is created. 
    ! 
    !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    

    Copy and paste the following SheerPower code into the get_headline routine on a blank line in between routine get_headline and end routine. The first line of code is indented 2 spaces under the routine statement with the rest of the code indented accordingly below.


      crlf$  = chr$(13) + chr$(10) 
      state$ = 'find_main' 
      do 
        line input #news_ch, eof eof?: text$ 
        if eof? then exit do 
        select case state$ 
        case 'find_main' 
          z0 = pos(text$, main$) 
          if z0 = 0 then repeat do 
          z0$ = mid(text$, z0+len(main$)) 
          z0  = pos(z0$, '>') 
          if z0 = 0 then repeat do 
          z0$ = mid(z0$, z0+1) 
          dbox$ = begin_form$ +z0$ 
          state$ = 'gather_news' 
        case 'gather_news' 
          z0 = pos(text$, end_main$) 
          if z0 > 0 then 
            dbox$  = dbox$ + left(text$, z0-1) 
            state$ = 'show_news' 
            repeat do 
          end if 
          dbox$ = dbox$ + text$ + crlf$ 
          repeat do 
        case 'show_news' 
          // 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>' 
          line input dialogbox dbox$: ans$ 
          exit do 
        end select 
      loop 
    

    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 Get Routine Name dialog box will appear. Type the name of the subroutine being created as complete_form.

    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. 
    ! 
    !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    

    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.


    Copyright 2003-2004 Touch Technologies, Inc. All rights reserved.
    Parts of the SheerPower technology are U.S. patent pending.


    Free SheerPower 4GL Download | SheerPower 4GL GOLD License Purchase Information
    SheerPower 4GL Online Documentation | Sample Programs
    SheerPower 4GL Technical Support | FAQ
    Getting Started Tutorial | Application Tutorial
    Submit Feedback | Contact Us
    SheerPower 4GL Home