Alternatives To Hp Basic Programming - HP 39gs Master Manual

Graphing calculator
Hide thumbs Also See for 39gs:
Table of Contents

Advertisement

39
A
H
P
B
P
A
H
P
B
P
L
T
E
R
N
A
T
I
V
E
S
T
O
A
S
I
C
R
O
G
R
A
M
M
I
N
G
L
T
E
R
N
A
T
I
V
E
S
T
O
A
S
I
C
R
O
G
R
A
M
M
I
N
G
The hp 39gs and hp 40gs are supplied with a simple and easy to use
programming language called HP Basic. This language is compiled
rather than interpreted, which means that when you run a program it is
translated into machine code before it is run. This saves time when
running but causes a slight pause the first time any program is run while
the translation process goes on. After the first time the compiled version
is remembered and re-used unless you edit the program. Other calculators often use an interpreted language
where each line is compiled only as it comes up for execution. There are advantages and disadvantages to
both methods.
The drawback of the HP Basic language is that it is relatively slow to execute when compared to a modern
computer and also that it is missing certain features commonly found in modern languages. The most
significant of these is string handling. Unfortunately there is no way to input a string (a set of characters), nor
can you work with strings or store them. In other words you can't, for example, ask the user what their name
is and then display messages addressed to them by name. This can be very frustrating to those used to other
languages but there are generally ways to work around this. The most common is to pop up a menu with
options from which the user can choose. The problem with this is that you have to know in advance what the
options are going to be – you can't easily re-program them on the fly based on user input.
The sRPL programming language
The speed issues and the lack of string handling, mean that programs such as games are not easy to create.
Some programmers choose to work instead in an alternative language called sRPL. For those who have some
programming background, this is an assembly code language. If you're not sure what this means, then
basically it means working at a language level where you are writing commands that are executed directly on
the chip rather than being compiled & translated by the calculator first. HP Basic is a language that is not far
removed from the way that humans think (mathematically at least). sRPL is not like this in that it is written in the
way that the chip 'thinks' instead. But it does offer both tremendous speed and string handling.
Unfortunately this means that the commands in sRPL are far harder to use and far more fiddly and verbose. A
program that takes five lines in HP Basic might take 50 lines or even more in sRPL. However it is quite likely
that those 50 lines will execute fifty to sixty times as fast as the five lines of HP Basic. The drawback is that
they will also have a much greater risk of containing a bug – the compiling process of HP Basic will spot most
simple bugs but sRPL has no such filter. It just does what you tell it to even if this means crashing the entire
calculator. It is an very powerful language to use but you need to be very careful or your code will regularly
crash the calculator. Additionally, while a crash in HP Basic will simply cause the program to stop
unexpectedly, a crash in sRPL may well cause the calculator to lock up or reset with complete loss of user
memory.
For those interested in learning HP Basic a series of tutorials can be found on the author's website at
http://www.hphomeview.com. Look for the Help page and find the programming section.
281

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

40gs

Table of Contents