HOME   UEDIT   UCALC   UPAC   USER-RPL PROGS
         
 

Introduction

Using the UEdit and UCalc Advanced Edition tools, you can create, run, and debug User-RPL programs for HP programmable calculators which feature User-RPL programming, such as the HP50g.  In this tutorial, we'll go through writing a simple "Hello" User-RPL program using the UEdit editor, and then use the UCalc User-RPL programmer to test and run it. 

You can also download the Hello project zip file here.

What is an User-RPL project?

An User-RPL project consists of a number of variables.  The variables can be any one of the object types supported by UCalc  (see the UCalc help function under the "Object Types Supported in UCalc" topic).  When variables are created and saved for a project, they are organzied in three folders in UEdit's "Project View":  GROB (Graphic Object) Variables, Non-GROB Variables, and Project GROB Designs.  Project GROB Design files are not really part of the User-RPL program, but are graphic designs you create for the program.  The UEdit GROB Editor let you create story boards for your program and saved them as Project GROB Design files.  An User-RPL project will have a project file name with the extension .hp2, such as helloProject.hp2

The "Hello" User-RPL project

Our simple "Hello" project consists of only one variable of program type.  The program will display a GROB which we will design using the UEdit GROB editor, a welcoming message, and a message to inform the user to press a keyboard key to exit the program.

Start the new project by selecting the File menu | New Project item.  Next start a new variable by either selecting File | New Variable or clicking the New Variable icon on the row of icons.  A variable temporarily named 'Variable 1' will appear with the header already filled in for you.  Since our variable is to be a program, next we click on the special characters << and >> to begin coding our program object.

Note that comment line starts with the character '@', and it must appear as the first character of a line.  Beside using '@' at the start of a line to designate a comment, the '@' character follows by a 'Z' character denotes some special functions relating to colors when executed in UCalc Advanced Edition.  We will go over their uses later on.  Next we will create some graphics for our program.

Before we start the next step, we save the variable and project.  Before saving the variable and project, create a directory C:\hello, where all files for this project will reside.  Save the variable as 'hello' and the project file (.hp2) as 'helloProject'.

Create the story board for our program

Use the UEdit's GROB editor's canvas to create the GROB to display.  The size of the drawing area is 131 X 80 pixels, which matches the size of the latest HP50g's screen.  However for our User-RPL programming environment, we will still use only 131 X 64 pixels.  We will also use the GROB editor to type in the messages to be displayed in the program.  The following shows the GROB and messages.

Create the Hello GROB

Use the tools in the UEdit's GROB Tool Box to create and edit your GROBs by clicking on the tool's icon.  For our example, you can draw the Hello GROB as shown above, or create your own graphics.  To center a region, click on the 'Select Region' tool, then position the mouse cursor on the pixel on the drawing area to start the region, and finally press and drag the mouse to define the region.  Once a region is defined, click on the 'Center Selected Region' tool to center the selected region.  To select whether to center a GROB vertically, horizontally, or both, click on the 'Grob Center Mode' tool.  Each subsequent click will select the next option.

Create the messages

To create the welcoming message on the GROB Editor, first select the character size to 3 (LARGE) by clicking repeatly the 'Character Size' tool.  Next set the start point on the canvas to begin typing in the character string by clicking the 'Select Point' tool.  The cursor will become an up arrow pointer.  Click on the pixel to select the start point.  Now type in "WELCOME TO USER-RPL".  You can center the string you just typed in by using the 'Center Selected Region' tool as described above.  Now repeat the same procedure for typing the strings "PROGRAMMING!" and "PRESS X TO EXIT".  For the last string, use character size SMALL.

Saving GROB or Project GROB Design files

You can save a selected region on the canvas as a GROB variable to be used in your program, or save the entire canvas (131 X 64 pixels) without first defining a selected region as a Project GROB Design file.  Saving as a project GROB design file is a way of saving your story board for your User-RPL project.  To save as a GROB variable, select a region, and click on the 'Save Grob To File' tool.  In our example, we will save the entire canvas as a project GROB design file.  The name of our file is preset to 'grobdesign1'.

Writing code for the Hello program

With our storyboard design finisWith our storyboard design finished, we can now start writing the User-RPL codes for the Hello program.  Recall that we can pass parameters to a program.  In the Hello program, we will pass a parameter to the inner program by using the operator '->'.  This operator can be inserted into the code by clicking the left arrow icon on the 'Special Characters' panel.  We will pass a GROB as a parameter to the inner program.  The parameter we will name 'hellogrob'.  The actual code for the GROB is easily generated by UEdit.  We want to assign to 'hellogrob' a grob we can extract from our GROB editor canvas.  We start by selecting a region on the GROB editor canvas, then on the code editor, after positioning the code insertion point, we select the 'Insert Grob Code' tool by clicking it.  That's it.  We can see the code automatically generated for the GROB that we have selected.  Notice the @ZGROBCOLORS line.  This is a command which specifies the color information for the GROB.  When the program is executed on UCalc Advanced Version, we will see the GROB in color.

Next, the codes to display the GROB, welcoming messages, and instructional message to exit are written in the inner program.  The following code initialize the UCalc or HP calculator's screen:

To display the welcoming message, we will use the REPL command.  UEdit makes it easy to insert code for a select point to display the message.  Recall that the code 'PICT {x y} grob REPL' is used to display a grob at the coordinate (x,y).  To generate the code for the coordinate automatically, first use the 'Select Point' tool in the GROB editor's tool box to select a coordinate to display the grob.  Then in the code editor, position the code insertion point.  Finally click the 'Insert Select Point' to generate the code for the coordinate.  The following show the codes for displaying the hello grob and the welcoming messages.

Notice that in the storyboard, the color of the text 'PRESS X TO EXIT' is blue.  We need to program this in the code.  We use the @ZCOLOR command to specify the pen color.  UEdit can generate this code for us easily.  First we select the pen color by clicking the 'Select Pen Color' tool in the GROB Tool Box.  Then back to the code editor and position the code insertion point, we click on the 'Insert Current Pen Color Code' tool icon.  The @ZCOLOR command will be inserted with the color information.  This command will specify the color to be used in the subsequent GROB display.  The following show the codes for setting the pen color and displaying the instructional message.

After displaying the hello grob, welcoming messages, and the instructional message, the Hello program will wait for the user to press X on the UCalc or HP Calculator's keyboard to exit.  For UCalc Advanced Edition, we can label the keyboard key(s) to provide a guide to the user as to what key(s) is valid to press for that program.  In the Hello program, we want to label the X key with the label 'Exit'.  To accomplish this easily, use the UEdit Advanced Edition's 'UCalc Key Labels Designer' tool under the Tools menu to program labels for the keyboard.

Notice in the UCalc Key Labels Designer above, we typed in 'Exit' in the text input box above the X key.  We can also change the label color and text color to achieve a custom look if we want.

The label information that we have programmed in the label designer must be inserted in the program if we are to display the label when executing the program in UCalc.  The @ZKEYLABELS command will serve that purpose.  To insert the @ZKEYLABELS code into our program, first we exit the Label Designer.  Back in the code editor and position the code insertion point, click the 'Insert Key Labels Code' icon to insert the @ZKEYLABELS code.  With this code, the program will display the label information on the UCalc's keyboard during execution.

One note about the Key Labels Designer, we can edit an existing keyboard label scheme.  First we highlite the @ZKEYLABELS code line in the code, and click the 'Edit Key Labels' tool icon.  We can then edit the existing labels if desire.  One final feature of the Key Labels Designer is we can turn off the label display at any point during our code execution.  To insert this code, click on the 'Insert Key Labels Off Code' tool icon.

Finally, we will write the User-RPL code to wait in a loop while checking the key input for the 'X' key press.  The following shows this code.

The completed program

We now have finished coding the Hello program.  We save the 'hello' variable one last time, and save the project also.  We are now ready to run it either on UCalc or on your HP calculator.  You can transfer the Hello project (which consists of one variable) to your HP calculator.  To do this, click to select the  'Download Project View' on UEdit, and drap and drop the helloProject.hp2 icon to your running HP calculator connectivity kit program.  In this tutorial, we will run the hello program on the UCalc Programmer Advanced Edition.

Overview of the UCalc User-RPL Programmer Advanced Edition

With UCalc, you can debug and run your User-RPL projects just like you are using your real HP48 series/HP49 series/HP50g calculators.  You can examine the user and system flags that you program in your code.  The debugging features let you single stepping each User-RPL function and command, and view the results on the stack.  You can insert HALT instructions in your code in UCalc to stop execution at any point of your code so you can start debugging from there.  In addition, the Advanced Edition add colors to your UCalc screen through the instructions you inserted in your code as discussed in the Hello project example. 

To run an User-RPL project developed using UEdit, select from the menu Tools | Project Manager.  The Project Manger lets you add a project, remove a project, or reload a project.  Reloading a project is useful when you are debugging a program.  The steps in writing and testing a program is you use UEdit to write/edit the program, and use UCalc to test it.  After you do testing, you might want to change or add code to your program in UEdit.  After changing and save your code in UEdit, you can reload the project in UCalc to update the project before testing it again.  You can select 'reload project' in the Project Manger to reload a project, or click on the 'reload project' icon located on the top row of icons in UCalc.

Running the Hello Program in UCalc Advanced Edition

We select 'add project'  in the Project Manager to add our Hello Program.  Enter { HOME HELLO } as the HP calculator directory where the variables for Hello will reside.  After the project is added, we can see that the directory hierarchy tree starting with the HOME node, and that HELLO is a subdirectory of HOME.  Within the HELLO directory, we find the program variable 'hello'.

With the hello variable (current variable) in focus, click on the run button to evaluate it.  You will see on the UCalc screen the Hello GROB, the welcoming message, and the instructional message.  Press on the X key to exit Hello.

Conclusion

You have taken a tour on using UEdit/UCalc to create and run fun User-RPL programs on your PC.  You can read the Help topics in each application to learn more about the functions of UEdit and UCalc.  With UEdit and UCalc, you will increase your knowledge and the usefulness of your HP programmable calculators. 

© Copyright 2013 Stanley H.H. Lui