HP Prime Programming Tutorial



Comments



Description

HP Prime Programming Tutorial #1: LOCAL, RETURNOver the next month, maybe month and a half, I plan to post programming tutorials for the HP (Hewlett Packard) Prime. If you have programmed with the HP 38G, 39g, or 39gii, this language will be similar to those. The programming language for the Prime is named the HP Prime Programming Language (HPPP). Throughout this tutorial, I am going to use the latest version of the software. How to start writing a program: 1. Press Shift + 1 (Program). 2. Press New. It is the second touch key. 3. Enter the name of the program. Pressing the ALPHA key twice will turn on UPPERCASE ΑLPHALOCK. Pressing ALPHA, Shift, ALPHA will turn on lowercase alpha-lock. To exit any lock, press the ALPHA key one more time. When happy with the name, press Enter. Rules for Program Names: 1. Letters, numbers, and the underscore character (_) only. 2. The program name must start with a letter. Structure of a HP Prime Program A HPPP program is encased of an EXPORT - BEGIN - END structure. The layout is generally like this: EXPORT program_name(arguments) BEGIN commands and comments go here  END; Each line containing a command generally must end with a semicolon (;). A semicolon can by type by pressing ALPHA then the Plus key ( + ). If there are no syntax errors. I use the Check command all the time. vectors. if the program TEST has four arguments.Comments can be typed. squares it. matrices. 1. because "Hello World" programs are so 2000s. select the User touch key. 2nd key from the left. Tip: You can check the syntax of the program just by pressing the Check soft key in the program editor. . select the program. SQIN takes a number. Access: Tmplt. Type the name. and input the required arguments. lists. separate each entry by pressing the Enter key. the Prime states "No errors in the program". 2. For example. Block. In short we are defining a custom function: SQIN(x) = 1/x^2 Commands: RETURN: returns a result to the stack (home page). END. it looks like a tool box). EXPORT SQIN(X) BEGIN RETURN 1/X^2. then calculates the reciprocal. The are designated by two forward slashes. HP Prime will inform you if there is a syntax error and attempt to point you to the error.Textbook Entry. and in the parenthesis state the number of arguments.Algebraic Entry. CAS Mode: Type the program name. SQIN Our first program is SQIN. the RPN stack would like this: 4: argument_1 3: argument_2 2: argument_3 1: argument_4 TEST(4) to run the program. or a combination of these times. Home Mode . strings. Follow the name with parenthesis and enclose the required arguments. The slashes are typed by pressing the Divide key ( ÷ ). Or use the Toolbox (top row of white keys. Anything in the line following the two slashes is ignored in running the program.RPN Entry: Enter each argument. You can return numbers. RETURN All the program code in this tutorial series will be shown in Courier font. How to run the programs: Home Mode . Home Mode . messages. which combine results. 9. RETURN "Payment ="+K.M) BEGIN LOCAL K:=R/1200. Parts are connected with a plus sign. MOPMT LOCAL: Declares any variables to be local to the program. EXPORT MOPMT(L.R. the interest rate (R).5. stores 1 in K and makes K a local variable. In other words. the variables are created. 30) returns 150.5. possibly displayed during program execution. FOR . and the number of months (M). 4. MOPMT calculates the monthly payment of a loan. used. TEXTOUT_P. 1.Examples to try with SQIN: SQIN(5) returns .  Tip: Use RETURN. The arguments are: the loan amount (L). Access: Tmplt.46534383 HP Prime Programming Tutorial #2: MSGBOX. Examples: MOPMT(4000. END.000771604938 The next program will demonstrate the concept of local variables. PRINT. IF-THEN-ELSE. and PRINT to return custom strings. For example: LOCAL K:=1.04 SQIN(36) returns . 3. LOCAL Tip: You can declare local variables and assign an initial value at the same time. and deleted at program termination. Variable. K:=L*K/(1­(1+K)^­M).317437565 MOPMT(370000. 360) returns 1661. and calculations. In this session. old-school combination locks.0. .Eddie (3/21/2014) Other commands that are featured: RANDINT(n. Access: Cmds. L0:=RANDINT(3. END. Program execution stops until you press a key to acknowledge the message."+L0(2)+". You can leave n out if you desire a single random integer.** MSGBOX("SECRET: "+L0(1)+". MSGBOX MSGBOX: MSGOX takes a string a makes a pop-up message box."+L0(3)). a.   ** Thanks to Thomas Lake for pointing out my typo. PRINT.Welcome to another programming tutorial for the HP Prime. The HP Prime's default list variables are designated L0 through L9. we will cover MSGBOX. 8. This program gives three digit combinations through the use of MSGBOX. Picks may be repeated. I/O.39). b) generates a list of n integers between a and b. 6. IF-THEN-ELSE. EXPORT COMLOCK() BEGIN LOCAL L0. Apologies for any inconvenience . MSGBOX The program COMLOCK: Imagine that you are in charge of setting the combinations for the good. and the FOR loop. Here is a sample output for COMLOCK: IF-THEN-ELSE IF-THEN-ELSE: Program structure: IF condition THEN do if the condition is true. etc. 2. 1. ≤. Branch. 6. by pressing Shift.  Access: Tmplt. Access <. ELSE do if the condition is false. IF THEN. ==. 2. END. IF THEN ELSE Tip: You can leave out the ELSE part if you only want to test to see if a condition is true. Note that the double equals is needed to check equality. 2. Access the simple IF-THEN structure by pressing Tmplt. . Branch. I/O.PRINT PRINT: The PRINT command prints a sting. You can access the terminal screen at any time by pressing the ON button. HComplex:=1. 9. and then pressing the Divide ( ÷ ) button. which allows for complex number results.B. result. . the program will end on the terminal (text output) screen. This is a good way to clear the terminal screen and I usually use this at the beginning of any program if PRINT is going to be used later on. PRINT(). The program QROOTS (yet one more quadratic solver. If PRINT is used. holding it. PRINT Tip: To clear the terminal screen. 6. EXPORT QROOTS(A. type PRINT().C) BEGIN LOCAL D. Press a button to exit. Access: Cmds. demonstrates the use of IF-THEN-ELSE and PRINT. or a combination of both onto the Prime's Terminal screen. sorry for not being original guys and gals). Here I set the setting variable HComplex to 1. 5-1. 1. PRINT((­B+?D)/(2*A)). CAS. 3. Featured Commands in SUMDIV: idivis: idivis(integer) returns a sequence of all of the divisors if integer. Each time a loop finishes. For sequences or vectors.D:=B^2­4*A*C. DIM must be used instead of SIZE to prevent a Bad Argument error."). Integer. LOOP. thevariable increases by one. 5.-8) returns: Roots are real. 12. END. and 6. END. Divisors Any CAS command used in programming will be preceded by "CAS. or matrix. 3. the divisors of 12 are 1. ELSE PRINT("Roots are complex.32287565553*i -2. Access: Tmplt. The sum is 28. END.5+1. All the commands in the loop will be executed a set number of times. 1. 2. DIM: returns the dimensions of a sequence. IF D?0 THEN PRINT("Roots are real. Access: Toolbox.8) returns: Roots are complex. 3.  Examples: QROOTS(1.2360679775 -1. .")." Not all CAS commands can be used in HP Prime programming at this time. -2. string.2360679775 FOR This section will explore the basic FOR structure: FOR variable FROM start TO end DO commands.32287565553*i QROOTS(2. The loop terminates when variable=end. FOR The program SUMDIV takes any integer and adds up the sum of its divisors.-4.5. 4. PRINT((­B­?D)/(2*A)). DIM returns the length in a list {length}. For example. Loop. Press the soft key Check to check your work. RETURN S. Access: Tmplt. the calculator gives you how may picks you needed to get the target number. which I had in this program was unnecessary. I hope you are ready for the intensity. 1. WHILE condition is true DO commands END. . For matrices.K. the calculator will tell you if number is higher and lower. ldiv:=DIM(mdiv). mdiv:=CAS. 5. DIM The program: EXPORT SUMDIV(N) BEGIN LOCAL S:=0. END. At the end of the game.   ** Thanks to Thomas Lake for pointing out that the variable "mat". KILL. INPUT: Creates an input screen for variables.For strings. SUMDIV(85) returns 108.idivis(N). FOR K FROM 1 TO ldiv(1) DO S:=S+mdiv(K).Eddie 3/21/2013 Examples: SUMDIV(12) returns 28. SUMDIV(24) returns 60. INPUT. DIM returns the list {number of rows. INPUT.mdiv.ldiv. TARGET is a game where you provide a guess to get a desired number. number of columns}. 9. REPEAT. :) WHILE. DIM returns length as a number. each with some new programming commands in this series. If you miss. GETKEY This tutorial is going to cover a lot. KILL HP Prime Program: TARGET. the input can asked for more than . Strings. WHILE Caution: Watch your ENDs! Make sure an END is with each loop and the program itself. WHILE: Repeat a number of commands while a specific condition is test. On the HP Prime. Access: Cmds. 3. END. HP Prime Programming Tutorial #3: WHILE. Block. G:=­1. you can adjust the higher limit. 5. IF G > N THEN MSGBOX("Lower"). END. You may include code of what to do if the user presses Cancel. list of "help text") Note: Pressing Cancel will store a 0 in variable. divide it by 2. I/O. Nothing dies. END. MSGBOX("Correct! Score: "+C)."1 ­ 20"). list of "labels". 1. KILL Program: EXPORT TARGET() BEGIN LOCAL C:=0. INPUT KILL: Terminates program execution. One Variable: INPUT(variable. Access: Tmplt. "title". multiply it by 3 and add 1. TARGET demonstrates INPUT with one prompt. 6. Try it and of course. INPUT(G. Access: Cmds. WHILE G?N DO C:=C+1. N:=RANDINT(1. Here is some thing for you to try with TARGET: 1. "help text") Multi-Variable: INPUT(list of variables. IF G==0 THEN KILL."GUESS:".20). Add a limited amount of guesses. ULAM counts how many steps it takes to get n to 1. 2. Can you display the list of guesses? REPEAT ULAM Algorithm: take an integer n. REPEAT: . If n is even. END."Guess?". END. but it is not required. If n is odd. 3. IF G < N THEN MSGBOX("Higher"). I promise.one input. "title". "label". END. Loop. REPEAT Featured: CONCAT(list1.{N}).Access: Tmplt. 11. 10. Math. GETKEY. 6. END. GETKEY: Returns the key code of last key pressed. 2. 8. OF STEPS="+C). 16. 16. 4. 2. 4. I/O. the code returns to the terminal screen. REPEAT IF FP(N/2)==0 THEN N:=N/2. ELSE N:=3*N+1. 1} GETKEY The next section will introduce a super-important command. 6.  Examples: ULAM(5) returns: Message Box: "NO. 3. 6. MSGBOX("NO. L0:={N}. Which each key press. 34. OF STEPS=16" List: {22. L0:=CONCAT(L0. 20. 13. END. 8. C:=C+1. list2): Melds list1 and list2 into one. The program terminates when the Enter key is pressed. The Prime's key map is below. 4. 17. 5. 4. Access: Toolbox. The Program KEYNO: The person presses key presses. List. 26. (Picture is from the HP Prime User's Guide) Access: Cmds. 40. OF STEPS=6" List: {5. Concatenate EXPORT ULAM(N) BEGIN LOCAL C:=1. GETKEY . RETURN L0. 1} ULAM(22) returns: Message Box: "NO. 52. UNTIL N==1. We will be working with GETKEY over the entire series. EXPORT KEYNO() BEGIN LOCAL K. END. UNTIL K==30. REPEAT K:=GETKEY. PRINT("Press any key to get its code."). IF K ? 0 THEN PRINT(K). . END. PRINT("Press Enter to exit."). PRINT(). "title string". major thanks to Han. There are two syntaxes for CHOOSE: Simple Syntax (up to 14 options): CHOOSE(var. Today's session will cover CHOOSE and CASE.. Use the IF THEN ELSE structure with INPUT to execute a set of default instructions if the user presses cancel. and 1 if a value is entered. "item 2". . 6. choosing item 2 assigns the value of 2 to var. "title string". similar to what you see when you click on a soft menu. INPUT returns a value of 0 if ESC or cancel is pressed. "Help". I/O. {"item 1".) THEN commands if values are entered ELSE commands if Cancel is pressed END.. Tip about INPUT Welcome to Part 4 of our programming series for the Prime. First a tip from Han of the MoHPC Forum. Access: Cmds. if you want var to be a string.org/cgisys/cgiwrap/hpmuseum/forum.. Again.cgi#255084.hpmuseum. Thank you Han for allowing me to share this. For example. "item 1". List syntax (infinite amount of items): CHOOSE(var. Choosing item 1 assigns the value of 1 to var.  Default values can be assigned to values as an optional fifth argument for INPUT. CHOOSE and CASE CHOOSE: Creates a pop up choose box. which is found at http://www. 1. "Prompt". "item n"). store an empty string: var:=" ".. INPUT(var. IF INPUT(. . "Title". CHOOSE . "item 2"}).Example Key Codes: 33: 8 key 2: up 7: left 8: right 12: down 50: plus 45: minus HP Prime Programming Tutorial #4: CHOOSE and CASE. Just remember to store such type before the INPUT command. default value) The type of variable maybe set to other than real numbers.  "Input Radius". CASE IF test 1 THEN do if true END. .1."1.149821209 ft/s AREAC . Also includes a default scenario (optional). CHOOSE(C. END. "R =").R.3403 ft^2 Terminal Velocity: T = 53. IF test 2 THEN do if true END. L1:={1."Object". 3."Sphere". INPUT(R.. Circle". INPUT({M. L2:={.{"Mass"."3.1.15."English")."Type of Object"."Cube". and Sectors EXPORT AREAC() BEGIN LOCAL C. 2.A. Sector"). CASE Let's look at two programs to demonstrate both CHOOSE and CASE.05 kg."Surface Area"}). {"M=".CASE: Allows for different test cases for one variable.S. A = . .Area of Circles."SI".. Rings.Terminal Velocity of an Object EXPORT TERMVEL() BEGIN LOCAL L0:={9. M = 1..0765}."A="}. T:=?((2*M*L0(C))/(L1(C)*A*L2(K)))."2.6640475387 m/s Cube.2 lb. CHOOSE(K. "Cylinder".04}.174}.  Examples: Sphere.M."Areas"."Units". Ring". RETURN T.  Access: Cmds."Tear­Shaped").A}.47. M = . CHOOSE(C.32.05. TERMVEL .0028 m^2 Terminal Velocity: T = 24.80665.. SI Units. MSGBOX("Terminal Velocity="+T).T. DEFAULT commands END.K.225. US Units. Branch.θ. A = .A.C. U# is for sequences of N. \\ Assume you are in the correct angle mode IF HAngle==1 THEN \\ Test Angle Mode θ:=θ*?/180. (Parametric App) V# for open statements and equations in the Advanced Graphing App. θ = π/4 radians or 45° Circle: 19.5. END. END. A:=?*(R^2­S^2). r = 1. "Angle". R# is for polar functions of θ. IF C==2 THEN  INPUT(S.5663706144 Sector: 2. (Polar app). N-1. END.CASE IF C==1 THEN A:=?*R^2. "θ="). A:=θ*R^2/2."Small Radius". X# and Y# for parametric equations of T. (Sequence app)."r="). Examples R = 2.6349540849 Ring: 12. RETURN A. F# is for functions of X. . END. RGB Today's session is about starting other apps in a program and using colors. END. N-2. Defining equations in the Program Editor and Home The equation must be a string and be stored to the appropriate designated variable.45436926062 HP Prime Programming Tutorial #5: STARTAPP. MSGBOX("Area is "+A). (Function app). IF C==3 INPUT(θ.5. END. STARTVIEW. which The independent variables are X and Y. Whether a function is analyzed in Num view. Starts the named App. It has two arguments. R5:="A*SIN(θ)" stores the polar function r(θ) = A*sin(θ) in Polar Function 5. 4. if you are in the Function app.# is a digit 0-9. Example: F1:="2*X^3" stores the function f(x) = 2*x^3 in Function 1. 4. UNCHECK STARTVIEW Instructs the HP Prime to go to a certain view. Access: Cmds. The calculator points the screen to the default view (Plot. App Functions. with A being what value stored in it. 2. Common view numbers include (not all inclusive): -2 = Modes screen -1 = Home 0 = Symbolic (Symb) 1 = Plot 2 = Numeric (Num) 3 = Symbolic Setup 4 = Plot Setup . 4. 4. Access for CHECK: Cmds. CHECK Access for UNCHECK: Cmds. Num). For example. App Functions. 2. STARTAPP STARTAPP(application name in quotes). Defining equations this way leaves them uncheck. Symb. 1. As you should expect. Whether a function is plotted in Plot view. CHECK(1) activates F. STARTAPP CHECK and UNCHECK Checks and unchecks specific equation or function (0-9) in the current app. you will need to check them. UNCHECK(1) turns F1 off. App Functions. If you want them plotted or accessed in Num View. What does CHECK and UNCHECK affect? 1. the view number and a redraw number. RGB codes: Blue: RGB(0. This is super useful for drawing and text writing.127.0) Yellow: RGB(0. I recommend the latter.0. Syntax: RGB(red. 2.75. redraw number) Access: Cmds. blue.128.330) For other colors. 0-255 Blue: Intensity of Blue.0) Dark Green: RGB(0. 0-255 Alpha: (optional) Opacity (up to 128).255.255) Black: RGB(0.128) Brown: RGB(150.0) Orange: RGB(255.0.0) White: RGB(255. green.255) Red: RGB(255. anything else does.0) Light Blue: RGB(173.216.255. 0 does not redraw the screen.5 = Numeric Setup 6 = App Information 7 = The Views Key 8 = first special view 9 = second special view Etc. 4. STARTVIEW RGB Returns an integer code pertaining to a color's RGB code. RGB can be found on various sites on the Internet.255) Violet: RGB(143.255..128. App Functions. Drawing. Access: Cmds. Syntax: STARTVIEW(view number. The redraw number is either 0 or non-zero. 0-255 Green: Intensity of Green. 5.0) Gray: RGB(129. 3. alpha) Red: Intensity of Red. RGB Tip: Change a color of a graph .0. including Wikipedia.  cb.0. { }.  .0.. "Red". {0.cb(I)).D.0. INPUT({A. "Choose a Color".255. orange.) ).0. Conic Drawing for HP Prime Draws the conic section for the general equation Ax^2 + By^2 + Cxy + Dx + Ey + F = 0 You can choose the color how the conic section is plotted.127. // Colors CHOOSE(I. cg:={0. . { }. R for polar.B.0.0.0."Blue". blue."Green"). and green. F stands for the designated function type (F for function. "Ax^2+By^2+Cxy+Dx+Ey+F". STARTAPP("Advanced Graphing").255}.0}).Use the syntax F#(COLOR):=RGB(red.0}. Let's see all these commands and tips in action and create some magic. but this is doable.0}.1). CHECK(1). cg.[alpha]). (Game show enthusiasts take note of the order of the colors I listed.255) makes the function F8 plot in blue. I. from red. END.C.. etc) # is the digit 0-9. EXPORT CONIC() BEGIN LOCAL cr.0. This is a lot. cb:={0.E.cg(I). cr:={255.blue.F}."Orange".255. V1(COLOR):=RGB(cr(I). V1:="A*X^2+B*Y^2+C*X*Y+D*X+E*Y+F=0". Example: F8(COLOR):=RGB(0. // Plot View STARTVIEW(1.green. Below are some examples. Remember the form: Ax^2 + By^2 + Cxy + Dx + Ey + F = 0 . .  G. where factors include the object being projected.Projectile Motion for HP Prime This program calculates range and height of a projectile. ≈32. θ are global // Degrees . The program sets the mode into Degrees (HAngle=1) and the calculator to the Parametric app.80665 m/s^2. EXPORT PROJ13() BEGIN LOCAL M. so we are dealing with ideal conditions.17404 ft/s^2) Air resistance is not factored. str. // V. How much the projectile represents reality varies.. the temperate and pressure of the air. Equations: x = V * cos θ * t y = V * sin θ * t .5 * g * t^2 Where V = initial velocity θ = initial degree of flight g = Earth gravitation constant (9. and the weather. and plots its path. "Initial Angle in Degrees"}). Height: "+Ymax+" "+str).7°.  Below are screen shots from an example with V = 35."θ:"}. G:=32.HAngle:=1.80665.1). "Data". Ymin:=0 // Height Ymax:=(V^2*SIN(θ)^2)/(2*G). END. INPUT({V. θ}. {"V:". // Adjust Window Xmin:=0 // Range Xmax:=V^2/G*SIN(2*θ). ELSE  str:="ft".17404. "SI". IF M==1 THEN str:="m". MSGBOX("Range: "+Xmax+" "+str+". . END.25 m/s and θ = 48. STARTAPP("Parametric").5*G*T^2". " +". Y1:="V*SIN(θ)*T­. {"Initial Velocity in "+str+"/s". "US"). X1:="V*COS(θ)*T". "Units". // Plot View STARTVIEW(1. CHECK(1). CHOOSE(M. G:=9. HP Prime Programming Tutorial #6: Subroutines Subroutines . If not. SUB1().Y) BEGIN LOCAL A. END.e^(x-y) .Y))^2. B:=(SUB1(X.  SUBEXAM This is just a demonstration of how sub routines work. SUB1(X. then the program evaluates A. IF A>B THEN RETURN A.  . ELSE RETURN B.Y) BEGIN RETURN 2*e^(X+Y)­e^(X­Y)­e^(Y­X). Definitely take a look at the example programs to get a better understanding. Where: A = 2(x-y)/Φ + xy B = Φ^2 and Φ = 2e^(x+y) . A:=(2*(Y­X))/SUB1(X. END. subroutines have be declared before the main program. B. Generally. END. sub() BEGIN commands go here END. The details of the subroutines are after the main program. the program values B instead.e^(y-x) We will use Φ as the subroutine.Y)+X*Y. including sub()  END. SUB Routines for HP Prime General Syntax: sub(). //declare subroutines EXPORT main() BEGIN  commands go here. EXPORT SUBEXAM(X.This session will show how routines work in HPPL. Declaration is important. This program calculates one of two values: If A is positive. z1. SUB2(X. // Main program EXPORT DDAYS(m1. END.X) BEGIN RETURN 365*Y+31*(M­1)+D+IP(Z/4)­X. 1) returns 21998.3) returns 86283.-3) returns 21810. If any such years are passed. ELSE RETURN IP(. SUB3(Y.x1). SUB1(X) BEGIN IF X?2 THEN RETURN 0. ELSE RETURN Y.m1.Hewlett Packard // Declare Subroutines SUB1(). Source: HP 12C Manual .m2.6046664 Days Between Dates DDAYS Using Subroutines for HP Prime: Best for 1901 to 2099 * Remember century years not divisible by 400 are NOT leap years. z1:=SUB2(m1.y2).648061288 SUBEXAM(2.4*X+2.y2) BEGIN // ΔDYS HP 12C LOCAL x1.y1.918189 SUBEXAM(2. x2:=SUB1(m2).m2. z1. RETURN SUB3(y2. SUB3(). END.2797974 SUBEXAM(-5. x2. x1:=SUB1(m1).d2.z2.3). z2.y1). z2:=SUB2(m2. subtract one day for such year manually.d1. END.D.-6) returns 30.M. END. SUB2().d2.d1.Y) BEGIN IF X?2 THEN RETURN Y­1. This program does not take this into account. END. .x2)­ SUB3(y1.Z.Examples: SUBEXAM(-4. END. Advanced Grpahing). and Ymax.506 BUT this program treats 2100 and 2200 as leap years. We touched on graphics a bit when we used STARTAPP and STARTVIEW to call up the Plot screen of certain apps (Function.397 days 12/10/2010 to 6/30/2014 is 1. This makes typing commands much easier.y) are these: * The end points depend on the Plot variables Xmin. * The trade is that some (very few) drawing commands don't accommodate the Cartesian system. which requires the radius to be in pixels. Parametric. Subtract 2 to get the correct answer of 77. Introduction OK this section we will start covering some of the graphics features of the HP Prime Programming Language. this might look familiar to you. Below is a map of the Cartesian system: . In a sense we are creating a graphic object (GROB). An example is the ARC command.. If you worked with the Hewlett Packard HP 39gii calculator. I hope everyone had a fantastic Thanksgiving. For those of you who are battling cold and stormy weather. For this tutorial series.G9. For those of you living in the Southern Hemisphere where summer is about to begin. The features of the Cartesian system (x. Ymin. Cartesian vs Pixel Each graphic object operates in either one of two coordinate systems: Cartesian and pixel. HP Prime Programming Tutorial #7: TEXTOUT Greetings everyone. (no shocker there).298 days 1/5/2015 to 3/19/2227 returns 77. The HP Prime allows for ten graphic objects. I'm jealous! :) I love summer..(Thanks to Owitte for pointing out my typo) Examples: Days Between Dates: 7/3/1985 to 2/28/1995 is 3. Xmax. please be safe.527 days 3/14/1977 to 11/17/2013 is 13. This time we are going to use drawing commands that can be used in any HP Prime app. * The system is familiar. (unless specified) I am always going to use the default GROB.504 days. named G0 . It has been too long since I last posted. G0. having x increasing as we move to the right and y increasing as we move up. Polar. which in reality they are not. On the other hand. The pixel (0.0) is the top left hand corner.The Pixel System (x. x and y are always non-negative. * The value of x still increases as we go to the right. However. y increases as we go down.y): * The boundaries are fixed. the pixel (318. opposite of the Cartesian system. 218) is the lower right hand corner. . RECT() is similar to PRINT(). freezes the screen. In a sense. Drawing. Hint: To paint an entire screen a specific color. Pixels Drawing Commands for the Cartesian system: Cmds. leaving it white.The Drawing Commands The HP Prime has two sets of drawing commands: one for the Cartesian system and one for the Pixel system. . The wipes the screen. Showing the Graphics Screen It is not enough to type the drawing commands. Cartésian Clearing the GROB screen To clear the GROB screen. Two ways to do it are: FREEZE: This does exactly what it says. 7. To exit. 2. We need a command to tell the HP Prime to show the graphics. All commands for the Pixel system will have a "_P" suffix attached. General Access: (in the Programming Editor) Drawing Commands for the Pixel system: Cmds. use RECT(color). while LINE_P draws a line using Pixel coordinates. 2. Drawing. It is necessary to do this at least at the beginning of each program containing drawing commands. we will simply type RECT(). 6. For example: LINE draws a line using Cartesian coordinates. tap the screen or press ESC. Optional. pressing any button will cause the program to continue. width*.Pressing Enter will re-execute the program. GROB*. the program terminates. 0: Current font size as set by Home Settings screen. results. Default is the current size set by Home Settings.θ. 2. If left out. respectively. width*: Length of the background box of the text. you can use WAIT(n) to make the calculator wait n seconds before executing the next step. background color*: Color of the background box. I usually don't use this argument. Of course. 1: Size 10 font 2: Size 12 font 3: Size 14 font 4: Size 16 font 5: Size 18 font 6: Size 20 font 7: Size 22 font text color*: The color of the text. text color*. GROB*: Graphic Object G0 through G9 to be used.t. Use of the RGB command is advised. They are also at the bottom of the Cartesian and Pixel Drawing sub menus. However. (Use either the x. TEXTOUT and TEXTOUT_P TEXTOUT and TEXTOUT_P inserts text on a graphics object using Cartesian and Pixel coordinates. 3. Full Syntax (starred commands are optional): Cartesian: TEXTOUT(text. Access: Cmds. respectively. y. Default color is black. Optional. It can be a string. Drawing. Simplified Syntaxes: Black text at default font size: . FREEZE WAIT(0): This freezes the screen for an indefinite amount of time. calculations. x: x coordinate y: y coordinate font size*: The text font's size code. Must be used if you want text to be a color other than black. Of course. x. y. I usually don't use this argument. font size*. x. width*.n button or the up button followed by Enter). GROB*. text color*. G0 is used. background  color*)  text: The text to be written. Optional. Optional. background  color*)  Pixel: TEXTOUT_P(text. font size*. or any combination. if the last END is followed by WAIT(0).  x.L0. Program: EXPORT SNOWFLAKE(N) BEGIN LOCAL X. y. SNOWFLAKE SNOWFLAKE takes one argument.RGB(0. FREEZE. [ × ] types *.X.TEXTOUT(text. The order regarding where to draw and generate random numbers is important to get the results you want.0.255). let's use TEXTOUT_P to draw snowflakes. Z:=RANDINT(1. light blue.4).255). Since it is December. END. y.Z).RGB(178. size code. color) TEXTOUT_P(text. FOR I FROM 1 TO N DO X:=RANDINT(0. TEXTOUT_P("*". END.255. x.2. x.Y.304). the symbol of multiplication in programming.255)}. which is the number of snowflakes to be drawn.208). y) TEXTOUT_P(text. L0:={RGB(0. Z:=L0(Z).Z.255. \\ save some room since text takes pixels Y:=RANDINT(0. y) Colored text at a set font size: TEXTOUT(text.255). dodger blue. cyan RECT(). and snowing in a lot of the northern side of Earth. Note: Take note the order of the commands. I am going to use symbolize the snowflake by the asterisk.  . we finally get to some programming. size code. \\ blue. color) With all this. x. RGB(30.Y.I.144. Documents Similar To HP Prime Programming TutorialSkip carouselcarousel previouscarousel nextHP CalculatorsHP Prime Programming Tutorial ABCProg Hp PrimeHP PRIME - PROGRAMA PARA CALCULO DE DISTANCIA Y AZIMUTProduct Comparison Tool_ Intermeclab 2 cs111Gradiente Hidráulico - Abastecimiento de Agua y AlcantarilladoProblemas Resueltos de Métodos Numéricos HP Prime Exercise BookProgramas HP-PrimeCURVAS SIMPLES HP PRIMEPaperProblemas Resueltos de Teoria de Maquinas y MecanismosMaths Lesson Pack Hp Prime and Hp39giiObject-Oriented Programming in Fortran 200363484 EnA Tutorial Introduction to the Language b - BtutIntroduction to Programming C++VLPRApplications of Linear AlgebraCelsis_5250_6250APSC 160 (UBC)Ends Functionsapnote_0000310154Brazil Condition-Based Tax Calculation in R3Technical Reference Manual - RAPID Instructions, Functions and Data TypeBdc Project Real timeASU Color PaletteARTIFICIAL PASSENGERMore From Mario AguirreSkip carouselcarousel previouscarousel nextF_I_(6).docxManual Maestro Construcor1Tipos de CementosF_I_(4)_AGUIRREIng. SismicaLos Proyectos de Irrigación en El PerúREACCIÓN ÁLCALIFII_(3)F_I_(5)F_I_(6)Tipos de CementosLos Proyectos de Riego en El PerúTipos de CementostopografiaFii (6) AguirreCemento y aplicaciones.docxParri Worlanalisis estaticoFii (5) AguirreReglam Correg y Arreglado Vale 1 Pata P. PPCCabalgatas Rancho El Diamante - Propuestas UltimoCabalgatas Rancho El Diamante -ChifasManual de SQLCorel IntroRedes CerradasFii (6) AguirreCapitulo10Best Books About Control FlowPROGRAMMING For BEGINNERSby iCodeAcademyAssembly Language:Simple, Short, And Straightforward Way Of Learning Assembly Programmingby Sherwyn AllibangIntroduction to Parallel Programmingby Steven BrawerC++ MCQs: Multiple Choice Questions and Answers (Quiz & Tests with Answer Keys)by Arshad IqbalProgramming with MATLAB: Taken From the Book "MATLAB for Beginners: A Gentle Approach"by Peter KattanLearning C# by Developing Games with Unity 5.x - Second Editionby Greg LukosekFooter MenuBack To TopAboutAbout ScribdPressOur blogJoin our team!Contact UsJoin todayInvite FriendsGiftsLegalTermsPrivacyCopyrightSupportHelp / FAQAccessibilityPurchase helpAdChoicesPublishersSocial MediaCopyright © 2018 Scribd Inc. .Browse Books.Site Directory.Site Language: English中文EspañolالعربيةPortuguês日本語DeutschFrançaisTurkceРусский языкTiếng việtJęzyk polskiBahasa indonesiaSign up to vote on this titleUsefulNot usefulMaster Your Semester with Scribd & The New York TimesSpecial offer for students: Only $4.99/month.Master Your Semester with a Special Offer from Scribd & The New York TimesRead Free for 30 DaysCancel anytime.Read Free for 30 DaysYou're Reading a Free PreviewDownloadClose DialogAre you sure?This action might not be possible to undo. Are you sure you want to continue?CANCELOK
Copyright © 2024 DOKUMEN.SITE Inc.