-- Beyond BASIC --
|FREE!! Download SheerPower 4GL NOW!||Documentation||SheerPower 4GL Technical Support Options||FAQ|
|Discussion Forum||Sample Programs||Contact Us|
SheerPower Programming QuestionsQ. 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?
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?
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!" else 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.
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)?
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 ?
open file myfile: name 'somefile.xxx', unformattted line input #myfile: rec$ // read a "chunk" of binary data firstbytes$ = left(rec$, 121) // Just the first 121 bytes
Where 'somefile.xxx' 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.
// 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$ end
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$ end
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?
login_url$ = 'http://some_url.com/' user$ = 'username' pass$ = 'password' open_url$ = 'http://some_url.com/newpage.html' // 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 do line input #http_ch, eof eof?: rec$ if eof? then exit do print rec$ loop end
Q. Can all the SUBMIT buttons in a Dialogbox form be removed?
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.
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" do 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 loop end
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?
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:
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?
for i = 1 to 3 media '@yes.wav' next i media '@sorry.wav' end
This example can be found in sheerpower\samples\play_sound.spsrc
Q. How do you handle scientific calculations with your limited range of
Q. In SPDEV, is there a way to get line numbers to appear next to the
lines to aid in debugging?
Q. How do I find EXCEPTION errors in my file easily?
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?
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?
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?
Note: SheerPower 4GL no longer supports Windows 98 or ME.
Q. How do I append data to a file in SheerPower?
open file myfile_ch: name 'myfile.txt', access outin do line input #myfile_ch, eof eof?: z0$ if eof? then exit do loop 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
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?
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?
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: