
28 Programming in HP PPL
This chapter describes the HP Prime Programming Language (HP PPL). In this chapter you’ll learn about:
●
programming commands
●
writing functions in programs
●
using variables in programs
●
executing programs
●
debugging programs
●
creating programs for building custom apps
●
sending a program to another HP Prime
HP Prime Programs
An HP Prime program contains a sequence of commands that execute automatically to perform a task.
Command Structure
Commands are separated by a semicolon ( ; ). Commands that take multiple arguments have those arguments
enclosed in parentheses and separated by a comma( , ). For example,
PIXON (xposition, yposition);
Sometimes, arguments to a command are optional. If an argument is omitted, a default value is used in its
place. In the case of the PIXON command, a third argument could be used that species the color of the pixel:
PIXON (xposition, yposition [,color]);
In this manual, optional arguments to commands appear inside square brackets, as shown above. In the
PIXON example, a graphics variable (G) could be specied as the rst argument. The default is G0, which
always contains the currently displayed screen. Thus, the full syntax for the PIXON command is:
PIXON([G,] xposition, yposition [ ,color]);
Some built-in commands employ an alternative syntax whereby function arguments do not appear in
parentheses. Examples include RETURN and RANDOM.
Program Structure
Programs can contain any number of subroutines (each of which is a function or procedure). Subroutines start
with a heading consisting of the name, followed by parentheses that contain a list of parameters or
arguments, separated by commas. The body of a subroutine is a sequence of statements enclosed within a
BEGIN–END; pair. For example, the body of a simple program, called MYPROGRAM, could look like this:
EXPORT MYPROGAM()
BEGIN
PIXON(1,1);
END;
552 Chapter 28 Programming in HP PPL
Komentarze do niniejszej Instrukcji