/PrimePlus

P+ is a proprietary programming language designed to mitigate the challenges associated with code maintenance and comprehensibility in the HP Programming Language (PPL).

Primary LanguageC++

P+

P+ is a proprietary programming language designed to mitigate the challenges associated with code maintenance and comprehensibility in the HP Programming Language (PPL). P+ serves as an intermediary language that addresses these issues by introducing support for pre-processing and facilitating code organization.

Variable & Constant

Using longer, more meaningful variable and function names can enhance code readability and ease maintenance. However, when targeting the HP Prime's PPL (Programming Language) with UTF16-LE text-based files, employing lengthy names can lead to larger .hpprgm files, which poses a downside. This is where substitution proves beneficial in P+.

var a:indexA;
const b:indexB:=1;
indexA += indexB; // Using subtitution.
a := a+b; // PPL results in a smaller .hpprgm file.

for...next

var I:index
for index:=0; index<10; index++ do
    // statement/s
next

do...loop

do
    // statement/s
loop

switch

var m:menuSelection;
switch menuSelection
    case 0 do
        // statement/s
    end
end

if condition do statement/s else statement/s endif

var e:hasError = true;
if hasError==true do
    // statement/s
else
    // statement/s
endif

if condition then return

if text=="" then return; // end; is optional as the pre-processor will automatically include end; if omitted.

guard condition else statement/s end

guard key != KeyCode.Esc else
    return
end

while...wend

var r:isRunning = true
while isRunning == true do
    // statement/s
    isRunning = false
wend

( condition ? true : false)

var a:myValue = 0
a = (X>Y ? 1 : 0);

def eval:... name(...);

var auto:alpha;
/// It is necessary to evaluate, as we are referencing a defined alias 'alpha' in the definition.
def eval:alpha := a setAlpha(a);
setAlpha(50.0);

#pragma

// Turn off C style bitwise operators :- ! ^ can now be used as math operations.
#pragma ( bitwise 0 )
// Minify your .hpprgrm file footprint
#pragma ( minify -1 )
// Turns off the automatic descending ordering of identities/aliases, once off it can't be turned back on.
#pragma ( unorderedness )

Obj-C Style

Warning

Deprecated: It must now be enabled #pragma ( messages ).

[Color ConvertToHSVFromRed:255 blue:127 green:0];

// Instead of:
Color::ConvertToHSV(255,127,0);

Pre-Calc

#define SCREEN_WIDTH 320
var a = #[SCREEN_WIDTH / #[8 - 6]];
// PPL LOCAL a:=160;
var b = #[SCREEN_WIDTH / 4];
b = #[SCREEN_WIDTH / 2]:2; // Pre-Calc #[]:scale
// PPL b:=160.00;
b = <calc>(SCREEN_WIDTH / 2:2);

Type Casting

Note

It may be removed in later updates, experimental purposes.

var R = 0.6;
I = <int>(R);
S = <string>(R);

Tip

In P+ the use of ; after end, endif, wend, loop ... is optional as the pre-processor will automatically include them if omitted.

Tip

In P+ the use of = for := is optional as the pre-processor will automatically covert all = to := Pascal & PPL style.

Important

In P+ = is treated as := were in PPL = is treated as ==

Note

The P+ proprietary programming language is susceptible to change, while also maintaining full compatibility with previous versions.