HP Prime/HP-BASIC/Commands

De TI-Planet Wiki
Aller à la navigation Aller à la recherche
This is a backup copy of the article from the old "HPWiki" of TI-Planet (that only hosted HP Prime info)

This is meant to be the repository of knowledge for HP-BASIC on the HP Prime. Commands are mostly grouped by the categories in the Help menu.

App Variables

App variables are variables for settings and results within a specific app. The variables are arranged by app.


For apps that yield results, each RESULTS variable can used in an expression. For example, the Function app enables you to calculate various critical points, such as intersections, roots, extrema, and the like. If, for example, you have used the Function app to calculate the roots of a function, you could select the Root variable and press Enter. The value of the variable is retrieved. You could also include Root in an expression, such as X^2–2*X+Root.

Note that variable names are case-sensitive.

App Variables Menu , Main/Variables/App Variables

Common

App variables store current settings and results in their respective apps. For example, the X Tick setting is stored in a variable, as is the angle measure setting and the graphing method setting.


You can change a setting by storing a value to an app variable or check a setting by evaluating an app variable and looking at it value.

The variables common to most apps are listed in this section. For variables specific to a particular app, see the section devoted to that app.

Common App Variables , Main/HP Apps/Common App Variables

Plot

View Variable Types

This section lists the variables common to many of the HP apps that have a Plot view.


Plot variables include, among other variables specific to the app, Xmin, Xmax, Xtick, Ymin, Ymax, and Ytick. Not all apps will have Plot view variables.

Common Plot View Variables , Main/HP Apps/Common App Variables/Common Plot View Variables

This section lists the variables common to many of the HP apps that have a Numeric view.

Common Numeric View Variables , Main/HP Apps/Common App Variables/Common Numeric View Variables

Xmin (Plot)

Sets the minimum horizontal value of the Plot view.

Xmin := n, where n is a real number

Xmin App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Xmin

Xmax (Plot)

Sets the maximum horizontal value in the Plot view.

Xmax := n, where n is a real number such that n>Xmin

Xmax App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Xmax

Ymin (Plot)

Sets the minimum vertical value of the Plot view.

Ymin := n, where n is a real number

Ymin App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Ymin

Ymax (Plot)

Sets the maximum vertical value in the Plot view.

Ymax := n, where n is a real number such that n>Ymin

Ymax App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Ymax

Xtick (Plot)

Sets the distance between tick marks for the horizontal axis.

Xtick := n, where n is a real number such that n>0

Xtick App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Xtick

Ytick (Plot)

Sets the distance between tick marks for the vertical axis.

Ytick := n, where n is a real number such that n>0

Ytick App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Ytick

Axes (Plot)

Turns axes on or off.

Axes := 0 — to turn axes on (default).
Axes := 1 — to turn axes off.

Axes App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Axes

Labels (Plot)

Draws labels in Plot view showing X and Y ranges.

Labels := 1 — to turn labels on.
Labels := 0 — to turn labels off (default).

Labels App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Labels

GridDots (Plot)

Turns the background dot grid in Plot view on or off.

GridDots := 0 — to turn the grid dots on (default).
GridDots := 1 — to turn the grid dots off.

GridDots App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/GridDots

GridLines (Plot)

Turns the background line grid in Plot view on or off.

GridLines := 0 — to turn the grid lines on (default).
GridLines := 1 — to turn the grid lines off.

GridLines App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/GridLines

Cursor (Plot)

Contains the cursor type in plot view.

• Cursor:=0 for normal
• Cursor:=1 for inverted
• Cursor:=2 for blinking

Cursor App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Cursor

Graphing Method (Plot)

Selects the graphing method:


Method:= 0, Adaptive (default): gives the most accurate results but takes longer to produce the graph

Method:= 1, Fixed-step segments: this method samples x-values, computes their corresponding y-values, and then plots and connects the points.

Method:= 2, Fixed-step dots: this works like the fixed-step segments method but does not connect the points.

Graphing Method App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Graphing Method

Recenter (Plot)

Specifies if the plot recenters on the cursor during Zoom operations in plot view.


Recenter := 0 — to recenter on cursor (default)
Recenter := 1 — not to recenter on cursor

Recenter App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Recenter

Xzoom (Plot)

Sets the horizontal zoom factor.

Xzoom := n, where n is a real number such that n>0 (default is 2)

Xzoom App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Xzoom

Yzoom (Plot)

Sets the vertical zoom factor.

Yzoom := n, where n is a real number such that n>0 (default is 2)

Yzoom App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Yzoom

Tmin (Plot)

Contains the starting value for T in parametric Plot view.

Tmin:=n, where n is a real number

Tmin App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Tmin

Tmax (Plot)

Contains the final value for T in parametric Plot view.

Tmax:=n, where n is a real number such that n>Tmin

Tmax App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Tmax

Tstep (Plot)

Contains the step value (increment) of T in parametric Plot view.

Tstep:=n, where n is a real number such that n>0

Tstep App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Tstep

Nmin (Plot)

Contains the starting value for N in sequence Plot view.

Nmin:=n, where n is a counting number

Nmin App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Nmin

Nmax (Plot)

Contains the final value for N in sequence Plot view.

Nmax:=n, where n is a counting number such that n>Nmin

Nmax App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/Nmax

θmin (Plot)

Contains the starting value for θ in Polar Plot view.

θmin:=n, where n is a real number

θmin App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/θmin

θmax (Plot)

Contains the final value for θ in Polar Plot view.

θmax:=n, where n is a real number such that n>θmin

θmax App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/θmax

θstep (Plot)

Contains the stepping value (increment) of θ in polar Plot view.

θstep:=n, where n is a real number such that n>0

θstep App Variable , Main/HP Apps/Common App Variables/Common Plot View Variables/θstep

NumStart (Numeric)

Sets the starting value for the independent variable in Numeric view when Automatic is the Num Type.


NumStart := n, where n is a real number

NumStart App Variable , Main/HP Apps/Common App Variables/Common Numeric View Variables/NumStart

NumStep (Numeric)

Sets the step size (increment) for the independent variable in Numeric view when Automatic is the Num Type.


NumStep := n, where n is a real number such that n>0

NumStep App Variable , Main/HP Apps/Common App Variables/Common Numeric View Variables/NumStep

NumType (Numeric)

Determines how the independent variable values in Numeric view are generated:


• Automatic: uses the NumStart and NumStep values to create the independent variable values.
• Build Your Own: you enter the independent variable values one by one.

NumType := 0 for Automatic (default)
NumType := 1 for BuildYourOwn

NumType App Variable , Main/HP Apps/Common App Variables/Common Numeric View Variables/NumType

NumIndep (Numeric)

Contains the list of values you have entered in Numeric view when you have chosen BuildYourOwn mode. In the case of the Advanced Graphing app, the list if of pairs of values.

NumIndep App Variable , Main/HP Apps/Common App Variables/Common Numeric View Variables/NumIndep

NumZoom (Numeric)

Sets the Numeric view factor.

NumZoom := n, where n>0 (default is 4)

NumZoom App Variable , Main/HP Apps/Common App Variables/Common Numeric View Variables/NumZoom

Program Catalog

Commands Menu

Drawing Commands

This menu contains commands for creating simple graphic objects, such as line segments, in graphic variables. There are 10 graphic variables in the HP Prime, called G0 to G9. G0 is always the current screen graphic and is used by default if no GROB is specified for any of the drawing commands.


G1 to G9 can be used to store temporary graphic objects (called GROBs for short) when programming applications that use graphics. Variables G1 to G9 are temporary and are cleared when the calculator turns OFF.

There are two identical sets of functions that can be used to modify graphic variables. The first set of them work based on Cartesian coordinates using the Cartesian plane defined in the current app by the variables Xmin, Xmax, Ymin, and Ymax in the Plot setup. The rest work on absolute pixel references based on the physical display of the HP Prime. For these functions, (0,0) is the top left pixel of the GROB, and (320,1240) is the bottom right. This second set of functions—those that work with pixels—have a _P suffix attached to their name, as in ARC_P and LINE_P.

In many of the commands, the color used can be specified as well. Unless otherwise specified,colors are defined in #A8R8G8B8 format (8 bits for R, G, B and A). It is highly recommended to use the RGB function when defining colors to provide compatibility for future devices in your programs.

If color is not specified for a drawing command, it will default to black unless otherwise specified.

Drawing Commands , Main/Program Catalog/Commands Menu/Drawing Commands

C→PX

Syntax: C→PX(x, y) or C→PXModèle:(x, yModèle:)


Transform cartesian coordinates into pixel coordinates. Returns a list.

C→PX , Main/Program Catalog/Commands Menu/Drawing Commands/C→PX

DRAWMENU

Syntax: C→PX(x, y) or C→PXModèle:(x, yModèle:)


Transform cartesian coordinates into pixel coordinates. Returns a list.

C→PX , Main/Program Catalog/Commands Menu/Drawing Commands/C→PX

C→PX

Syntax: DRAWMENU(Modèle:(text...Modèle:)) or DRAWMENU(text..)


Draw a menu containing the items specified

DRAWMENU , Main/Program Catalog/Commands Menu/Drawing Commands/DRAWMENU

FREEZE

Syntax: FREEZE

Prevents the screen from being redrawn after the program ends. Leaves the modified display on the screen for the user to see.

FREEZE , Main/Program Catalog/Commands Menu/Drawing Commands/FREEZE

RGB

Syntax: RGB(R, G, B, Modèle:BrOAModèle:BrC)


Returns an integer number that can be used as the color parameter for a drawing function. Based on Red, Green and Blue components values (0 to 255).

If Alpha is greater than 128, returns the color flagged as transparent. There is no alpha channel blending on Prime.

RGB , Main/Program Catalog/Commands Menu/Drawing Commands/RGB

Drawing Types

The commands for drawing using pixel coordinates are listed in this section.

Pixels , Main/Program Catalog/Commands Menu/Drawing Commands/Pixels

The commands for drawing using cartesian coordinates are listed in this section.

Cartésian , Main/Program Catalog/Commands Menu/Drawing Commands/Cartésian

ARC (Pixels & Cartésian)

Syntax: ARC_P(G, x, y, r, Modèle:BrOModèle:BrO∠1, ∠2Modèle:BrC,Modèle:BrOcolorModèle:BrCModèle:BrC)


Draws a circle on GROB G, centered at (x,y), with radius r. If ∠1 and ∠2 are specified, draws an arc from ∠1 to ∠2 using the current angle mode.

ARC_P , Main/Program Catalog/Commands Menu/Drawing Commands/Pixels/ARC_P , Pixels Variant

BLIT (Pixels & Cartésian)

Syntax: BLIT_P(Modèle:BrOtrgtGModèle:BrC, Modèle:BrOdx1, dy1Modèle:BrC, Modèle:BrOdx2, dy2Modèle:BrC, srcG, Modèle:BrOsx1, sy1Modèle:BrC, Modèle:BrOsx2, sy2Modèle:BrC, Modèle:BrOcModèle:BrC)

Copies the region of graphic srcG between point (sx1,sy1) and (sx2, sy2) into the region of trgtG between points (dx1, dy1) and (dx2, dy2). Does not cpoy pixels from srcG that are color c.

The defaults for the optional arguments are:
trgtG=G0
srcG=G0
sx1, sy1=srcGRB top left corner
sx2, sy2=srcGRB bottom right corner
dx1, dx2=trgtGRB top left corner
dx2, dy2=calculated so destination area is the same as source area
c=all pixel colors

BLIT_P , Main/Program Catalog/Commands Menu/Drawing Commands/Pixels/BLIT_P , Pixels Variant

When using BLIT with different GROBs, you must initialize them first. DIMGROB_P(Gn,320,240); initializes GROB n with the screen dimensions.

DIMGROB (Pixels & Cartésian)

Syntax: DIMGROB_P(G, w, h, Modèle:BrOcolorModèle:BrC) or DIMGROB(G, list)


Sets the dimensions of GROB G to w*h. Initializes the graphic G with color or with the graphic data provided in list. If the graphic is initalized using the graphic data, then list is a list of integers. Each integer, as seen in base 16, describes one color every 16 bits.

Colors are in A1R5G5B5 format (ie, 1 bit for alpha channel, and 5 bits for R, G, and B).

ARC_P , Main/Program Catalog/Commands Menu/Drawing Commands/Pixels/ARC_P , Pixels Variant

GETPIX (Pixels & Cartésian)

Syntax: GETPIX_P(Modèle:BrOGModèle:BrC, x, y)

Returns the color of the pixel of G with coordinates (x,y).

GETPIX_P , Main/Program Catalog/Commands Menu/Drawing Commands/Pixels/GETPIX_P , Pixels Variant

GROBH (Pixels & Cartésian)

Syntax: GROBH_P(G)

Returns the height of G.

GROBH_P , Main/Program Catalog/Commands Menu/Drawing Commands/Pixels/GROBH_P , Pixels Variant

GROBW (Pixels & Cartésian)

Syntax: GROBW_P(G)

Returns the width of G.

GROBW_P , Main/Program Catalog/Commands Menu/Drawing Commands/Pixels/GROBW_P , Pixels Variant

INVERT (Pixels & Cartésian)

Syntax: INVERT_P(Modèle:BrOGModèle:BrC, Modèle:BrOx1, y1Modèle:BrC, Modèle:BrOx2, y2Modèle:BrC)

Inverts the rectangle on G defined by the diagonal points (x1,y1) and (x2,y2). The effect is reverse video.

The following values are optional and their defaults are listed:
x1, y1=top left corner of G
x2, y2=bottom right corner of G

If only one (x,y) pair is specified, it refers to the top left corner of G.

INVERT_P , Main/Program Catalog/Commands Menu/Drawing Commands/Pixels/INVERT_P , Pixels Variant

LINE (Pixels & Cartésian)

Syntax: LINE_P(Modèle:BrOGModèle:BrC, x1, y1, x2, y2, Modèle:BrOcolorModèle:BrC)


Draws a line on GROB G between points (x1,y1) and (x2,y2).

LINE_P , Main/Program Catalog/Commands Menu/Drawing Commands/Pixels/LINE_P , Pixels Variant

PIXOFF (Pixels & Cartésian)

Syntax: PIXOFF_P(Modèle:BrOGModèle:BrC, x, y)


Sets the color of the pixel of G with coordinates (x,y) to white.

PIXOFF_P , Main/Program Catalog/Commands Menu/Drawing Commands/Pixels/PIXOFF_P , Pixels Variant

PIXON (Pixels & Cartésian)

Syntax: PIXON_P(Modèle:BrOGModèle:BrC, x, y, Modèle:BrOcolorModèle:BrC)


Sets the color of the pixel of GROB G with coordinates (x,y).

PIXOFF_P , Main/Program Catalog/Commands Menu/Drawing Commands/Pixels/PIXOFF_P , Pixels Variant

RECT (Pixels & Cartésian)

Syntax: RECT_P(Modèle:BrOGModèle:BrC, Modèle:BrOx1, y1Modèle:BrO, Modèle:BrOx2, y2Modèle:BrC, Modèle:BrOedgeColorModèle:BrC,Modèle:BrOfillColorModèle:BrC)

Draws a rectangle on G, with a diagonal defined by points (x1,y1) and (x2,y2), using edgeColor for the perimeter and fillColor for the inside.

The following values are optional and their defaults are listed:
x1, y1=top left corner of G
x2, y2=bottom right corner of G
edgeColor=white
fillColor=edgeColor

Note: To erase a GROB, execute RECT(G). To clear the screen, execute RECT().

INVERT_P , Main/Program Catalog/Commands Menu/Drawing Commands/Pixels/INVERT_P , Pixels Variant

SUBGROB (Pixels & Cartésian)

Syntax: SUBGROB_P(srcG, Modèle:BrOx1, y1Modèle:BrC, Modèle:BrOx2, y2Modèle:BrC, trgtG)

Sets graphic trgtG to be a copy of the area of srcG between points (x1,y1) and (x2,y2). If both (x1, y1) and (x2, y2) are not specified, then the entire graphic srcG is used. If (x1,y1) is not specified, then the top left corner of srcG is used; if (x2,y2) is not specified, then the bottom right corner of srcG is used.

trgtGRB can be any of the graphic variables except G0.

SUBGROB(G1,G4) will copy G1 in G4.

SUBGROB_P , Main/Program Catalog/Commands Menu/Drawing Commands/Pixels/SUBGROB_P , Pixels Variant

TEXTOUT (Pixels & Cartésian)

Syntax: TEXTOUT_P(text, Modèle:BrOGModèle:BrC, x, y, Modèle:BrOfontModèle:BrC, Modèle:BrOtextColorModèle:BrC, Modèle:BrOwidthModèle:BrC, Modèle:BrObackgroundColorModèle:BrC)

Draws text on graphic G at position (x, y) using font. Paints the background before drawing the text using color backgroundColor. If width is specified, does not draw text more than width pixels wide. If backgroundColor is not specified, the background is not erased.

The sizes for font are:

0=current font (default)
1=font_10
2=font_12 (Small)
3=font_14 (Medium)
4=font_16 (Large)
5=font_18
6=font_20
7=font_22

SUBGROB_P , Main/Program Catalog/Commands Menu/Drawing Commands/Pixels/SUBGROB_P , Pixels Variant

If you supply TEXTOUT a negative width, the text becomes italicized and underlined, ignoring the backgroundColor.