SheerPower® 4GL -- Beyond BASIC --

Programming FAQ

FREE!! Download SheerPower 4GL NOW! Documentation SheerPower 4GL Technical Support Options FAQ
Discussion Forum   Sample Programs Contact Us
General Questions

Development Environment Questions

Programming Questions

SheerPower License Questions

Uninstall/Repair Questions

SheerPower 4GL Home

SheerPower Programming Questions

Q. Are variables in SP4GL case sensitive?
A. No, SP4GL does not see any difference from a variable named x$ and X$.

Q. Can I do port I/O and serial port control operations from SheerPower?
A. Yes, SheerPower 4GL has COM port support. Please see the chapter in our documentation on Writing Network Applications and Accessing Devices. The end of that chapter contains the section on Communication Port Support.

Once the COM port has been opened, you just PRINT or INPUT to/from the COM port. When INPUTTING, if there is no data you will get back a zero-length string.

Q. I create programs that generate "gcode", the language of CNC machines used all over the world to fabricate countless items used in daily life. I need very precise math. Can SheerPower provide me with the mathematical precision that I need?
A. Yes. We devoted a huge amount of time in developing our own patented math package. The math package (called Perfect Precision) avoids all of the "floating point math" precision problems that one always encounters. Details on SheerPower 4GL's "Perfect Precision" math package can be seen at:

  Perfect Precision Math

Also on that webpage is a link to an IBM sponsored site that explains in GREAT DETAIL the failing of "floating point math" in delivering accurate results. A very simple program that you can try in any programming language is:

          x = 301.840002 - 301.000001
          if x = .840001 then
          print "Perfect precision!"
          print "Not quite right...sorry."
          end if

When using "C" or Visual BASIC or most any programming language, you will get the "Not quite right...sorry" message. With SheerPower 4GL you will, of course, get the "Perfect precision!" message.

Q. Are there any caveats or pitfalls that the user should know about in the SheerPower 4GL math engine? A good example of a "pitfall" that I'm referring to is the infamous behavior of a program when the dreaded zero denominator is executed. I have had almost every oddity happen, from total lockup to huge number answers. Many programs will spit out a "divide by zero" error, but some do not.
A. One caveat of our "Perfect Precision" math package is that it does not support numbers greater than ten-to-the-18th-power. So, this limits its use when large magnitude numbers are required.

Re: the zero denominator error--SheerPower 4GL does return a "division by zero" error.

Q. Does the Sending Email feature support Bcc and marking emails as a high priority (set a flag)?
A. Neither of those functions are currently supported.

Q. Can I use Javascript rollovers with the Input Dialogbox statement?
A. You cannot do Javascript rollovers in INPUT DIALOGBOX, but you can make a fancy user-interface with all of the browser features by writing a HANDLER, then use the browser for your user-interface.

Check out the CGI Interface section in the Writing Network Applications and Accessing Devices chapter of the documentation:

Q. I need to read several records of 121 characters out of a binary file. In BASIC I would use the Input$ function. Since there is no Input$ function in SheerPower, how can I reach the same goal ?
A. You would use the following code:

          open file myfile: name '', unformattted
          line input #myfile: rec$  // read a "chunk" of binary data
          firstbytes$ = left(rec$, 121)  // Just the first 121 bytes

Where '' is the name of your binary file.

Q. How do I send output to a printer in SheerPower 4GL? I would like to use your program to create a simple database program that generates purchase orders and invoices.
A. Try the following code:

          //  Create your output text file:
          outfile$ = 'myfile.txt'
          open file out_ch: name outfile$, access output
          for i=1 to 100
            print #out_ch: i, sqr(i)
          next i
          close #out_ch

          // Now print it out to the default printer
          pass print: outfile$

The other way to do this is to output HTML code instead. Then envoke the browser to display and print it:

          //  Create your output html file
          outfile$ = 'myfile.html'
          open file out_ch: name outfile$, access output
          print #out_ch: '<html><body>'
          print #out_ch: '<table border=3 bgcolor=lightblue>'
          for i=1 to 100
            print #out_ch: '<tr>'
            print #out_ch: '<td>'; i; '<td>'; sqr(i)
            print #out_ch: '</tr>'
          next i
          print #out_ch: '</table>'
          print #out_ch: '</body></html>'
          close #out_ch

          // Now have the browser handle it
          pass url: outfile$

You can create high-performance dynamic web applications now in SheerPower 4GL with the new web scripting feature. See the SheerPower Web Scripting chapter in our documentation. It's simple to use, powerful and very secure!

Q. In my SheerPower program, how do I login to a URL with a username and password, and then go to a different URL within that site and gather the HTML code from that page?
A. The following code example illustrates this task:

          login_url$ = ''
          user$      = 'username'
          pass$      = 'password'
          open_url$  = ''

          // log them in
          open file http_ch: name 'http-post://' + quote$(login_url$),
                          data 'ulogin='+user$ +
                               '&uhaslo=' + pass$
          close #http_ch

          // grab data from webpage

          open file http_ch: name open_url$

          // Now display all of the html that we get back
           line input #http_ch, eof eof?: rec$
           if eof? then exit do
           print rec$


Q. Can all the SUBMIT buttons in a Dialogbox form be removed?
A. Currently you can not eliminate all submit buttons. You must have at least one.

Q. When using the <select> tag in a Dialogbox, is it possible to get the dropdown default choice to be a variable passed via an existing data file? For example, having a form containing a <select> drop-down list to select your age, and you can choose any age, save the form, then later return to the form and see your last choice displayed as the default option.
A. The way to do this is to regenerate the DIALOGBOX string placing the default where it needs to be:

        form_menu$ = '<form>' 
        form_menu$ = form_menu$ + 'Age: <select name=age>' 
        form_menu$ = form_menu$ + '<option value="_age_">_age_' 
        form_menu$ = form_menu$ + '<option value="21">21' 
        form_menu$ = form_menu$ + '<option value="22">22' 
        form_menu$ = form_menu$ + '<option value="23">23' 
        form_menu$ = form_menu$ + '</select>'
        form_menu$ = form_menu$ + '</form>' 

        last_age$ = "23"
          default_age$ = last_age$
          default_form$ = replace$(form_menu$,'_age_='+default_age$)
          input dialogbox default_form$: choice$ 
          if _exit then exit do
          for item = 1 to pieces(choice$, chr$(26)) 
            z0$ = piece$(choice$, item, chr$(26)) 
            varname$ = element$(z0$, 1, '=') 
            value$   = element$(z0$, 2, '=') 
            select case varname$ 
            case 'age' 
              last_age$ = value$ 
            end select
          next item 

Q. Why is your compiler so slow when I run the following code?:

          x = 1
          y = 1.000001
          for i = 1 to 100000000
              x = x * y
          next  i
          print  x

A. We compile the above example in less than 1/1000th of a second. But, to then do the 100 million perfect-precision calculations *does* take some time.

All of the math is done in software (no hardware machine instructions because they lose precision instantly). With SheerPower 4GL you will *never* have penny rounding errors and incorrect answers. The hardware math is MUCH faster -- but always wrong with dealing with dollars and cents.

Q. What are the ARSBACKUP.EXE and ARSRESTORE.EXE programs found in the ARS folder?
A. They are both tools for use with ARS (Advanced Record System). ARSBACKUP backs up .ARS files while they are in use, with no data loss. When backing up multiple ARS files, they are all SYNCHED BEFORE the backup begins -- so all data is self-consistant between .ARS files.

ARSRESTORE restores .ARS_BACKUP files back to the original .ARS file.

Their syntax is just like COPY. But the behavior is different in these ways:

  • The OUTPUT SPEC must be a PATH (no file names or filetypes)
  • The INPUT PATH and OUTPUT PATH must be DIFFERENT (prevents files from accidentally being clobbered)
  • For ARSBACKUP, any .ARS files are copied as .ARS_BACKUP files
  • For ARSRESTORE, any .ARS_BACKUP files are copied as .ARS files

For example, inside the Command Prompt program window:

        // backup everything
        c:\sheerpower\ars\arsbackup *.*  d:\backups\payroll\

        // backup just the ARS files
        c:\sheerpower\ars\arsbackup d:\payroll\*.ars  d:\newpayroll\

For advanced backups and restores, you can specify a COMMAND FILE:

  ARSBACKUP - include backupfile.ars_cmd

This TEXT FILE consists of one or more text lines. Each line has the format of:


ARSBACKUP gathers together ALL of the INPUTSPEC files and synchs them before starting the backup. This allows .ARS files to be synched and backed-up when they are in multiple folders.

Note: For ARSBACKUP to be efficient, the ARS files should be in NON-SHARED folders. ARS files in SHARED FOLDERS will be LOCKED for the duration of the backup! (In non-shared folders no files are locked even while the backup is running -- providing 24/7 application operations).

See the overview of ARS for more information.

Q. Can I play .WAV files with SheerPower?
A. The MEDIA statement will allow you to play WAV files. For example:

        for i = 1 to 3
          media '@yes.wav'
        next i
        media '@sorry.wav'

This example can be found in sheerpower\samples\play_sound.spsrc

Q. How do you handle scientific calculations with your limited range of real numbers?
A. Currently we don't support anything over 10^18th. We are definitely looking into extending into the higher realms -- but it is not going to be anytime this next year. Our current focus was for PRECISION and not for MAGNITUDE. So, we did the trade-off of 34 digits of precision for our first cut. We do however understand the requirement in scientific fields for the high magnitude numbers.

Q. In SPDEV, is there a way to get line numbers to appear next to the lines to aid in debugging?
A. We have added this feature to our "WISH LIST". For now, when there is an error, you can double-click on the error text in the SPDEV output window (the BUILD tab at the bottom) -- and it will take you to the error line. If the Build tab is not displayed, click on "Display" in the toolbar then select "Results Window".

Q. How do I find EXCEPTION errors in my file easily?
A. For finding EXCEPTIONS (at runtime), you can PULL DOWN on the "---Routine Definitions ---" menu in the SPDEV toolbar. Choose the routine that has the error. SPDEV will automatically place your cursor at the start of the routine.

Then you can use the ALT/DOWN keystroke (Alt key + Down Arrow key) and move down the file to the line in the routine that the exception occurred. The "How many lines" dialog box will open:

Just enter the line# offset from the exception. For example, if the exception error was:

        Division by zero at DO_TOTALS.0005

This means a division by zero error is in the routine named "DO_TOTALS", the 5th line down. You would then choose "DO_TOTALS" from the Routine Definitions list, press Alt/Down arrow and enter in a 5. SPDEV will then place your cursor in the 5th line down from the start of that routine.

Q. Does SheerPower 4GL have a GUI editor?
A. Although SheerPower doesn't have its own GUI editor, you can send HTML code directly to the browser using the new web scripting functionality in SheerPower. See the SheerPower Web Scripting chapter in our documentation. It's simple to use, powerful and very secure!

Or, you can use any HTML GUI editor to make your forms. Then you can use the Input Dialogbox statement to use the form you created with the HTML GUI editor.

        INPUT DIALOGBOX '<sheerpower src="location of your HTML form">': resp$

Q. How can I write recursive routines?
A. SheerPower 4GL currently does not support recursion. Our BUG STUDIES showed that over 90% of the time, the recursion was unintentional. However, at some point we will be implementing:

        recursive routine xxxx...
        end routine

This will make it clear to the code maintenance people that the intent is for recursion.

Q. On Windows 98, I am trying to run a SheerPower sample ODBC program but I get the error "failed to load resource DLL odbcint.dll". How do I fix this?
A. To resolve this error you will need to install the Open Database Connectivity (ODBC) "add-on" component found on your Windows 98 CD-ROM. This will install the correct .DLL files necessary to run the program.

Note: SheerPower 4GL no longer supports Windows 98 or ME.

Q. How do I append data to a file in SheerPower?
A. The following example shows how you can append data to a file using SheerPower:

        open file myfile_ch: name 'myfile.txt', access outin
          line input #myfile_ch, eof eof?: z0$ 
          if eof? then exit do
        print #myfile_ch: 'This is a new line added to the file' 
        close #myfile_ch

Q. How do I precompile a .SPINC file in order to make a precompiled SPLIB (library)?
A. Currently, the way to precompile an .SPINC file is:

  • Rename your .SPINC file to a .SPSRC file.

  • DEPLOY the .SPSRC file -- this might require DECLARING variables and such right now to avoid various error messages. An .SPRUN file will be created.

  • Rename the .SPRUN file to a .SPLIB file

  • Rename the .SPSRC file back to a .SPINC file

Now you can call the SPLIB file in your program as follows:

  %include library 'filename.splib'

Creating the SPLIB file allows you to have routines used by applications that cannot be seen by anyone (i.e. if passwords are hard-coded in a routine). This functionality will be more fully integrated at a later date.

Q. How do I change the default fonts inside a DIALOGBOX or MENU?
A. You can change the default appearance of a MENU by opening the console window by clicking on its icon in the SPDEV toolbar (the blue square with a lightning bolt through it) and choose:

  Options -- Colors or Fonts

The "Menus..." and "Menu Headings..." options allow you to make changes to the default font settings for menus.

Alternatively, you can use "input dialogbox" and create a drop down SELECT menu in a dialogbox window, where you can put in your own background image, colors and different fonts. See Chapter 9 in the SheerPower documentation:


To change the default appearance of a DIALOGBOX, open the console window by clicking on its icon in the SPDEV toolbar (the blue square with a lightning bolt through it) and choose:

  Options -- Colors or Fonts

The "Dialog Box Input..." and "Dialog Box Display..." options allow you to make changes to the default font settings for dialogboxes.

Q. Will changing the colors and font in the console window stay even during distribution to other computers?
A. No, you have to include the following .INI file and install it on the other computers in order for your color and font changes to remain:


Where "xxxx" is the name of user's LOGIN name.

This .INI file can be found in your SheerPower folder--the default installation location is:


Questions, comments and suggestions are welcome!

Copyright (c) 2003-2016 Touch Technologies, Inc. All rights reserved.
Parts of the SheerPower technology are U.S. patented under patent#s 6822586, 7149765, and 8164492