P+

Prime Plus Language

About P+

P+ is a proprietary programming language designed to mitigate the challenges associated with code maintenance and comprehensibility in the HP Programming Language (PPL). PPL does not support pre-processing or multiple files, resulting in a single large file that can be unwieldy to manage. P+ serves as an intermediary language that addresses these issues by introducing support for pre-processing and facilitating code organization. P+ code is pre-processed into a single PPL file, which is subsequently executed on the HP Prime calculator since PPL is an interpreted language.

Insoft exclusively employs a proprietary programming language known as P+ for developing software intended for the HP Prime. Insoft has made the decision to release the software responsible for converting P+ to PPL to the general public. This software, developed internally, allows external developers to utilize the specialized programming language by seamlessly converting their own code written in P+ into PPL.

note:
The P+ proprietary programming language is susceptible to change, while also maintaining a certain degree of compatibility with previous revisions.
v1.3.2  Windows 10/11 x64   |   Windows 10/11 x86  |   Linux  |   Linux ARM 64-bit |   Raspberry Pi 64-bit  |  (70 downloads)
v1.3.1 Unit Tests
C Test Code (0.1.1) 
10
C- Library 
8
C to PPL Translator Pre-Release
 macOS   |   Windows 10/11   |  (3 downloads)

Syntax Help v1.3.2

1. If-Else

When ever you want to perform a set of operations based on a condition If-Else is used.

Prime Plus Language (P+)
if expression {
    // code for 'expression' is true
else:
    // code for 'expression' is false
}
HP Prime Programming Language (PPL)
IF expression THEN
    // code for 'expression' is true
ELSE
    // code for 'expression' is false
END;

2. Switch-Case

Switch-case is an alternative to If-Else-If ladder.

Prime Plus Language (P+)
switch expression {
    case condition1:
        // statements

    case condition2:
        // statements

    .
    .
    .

    case conditionN:
        // statements

    default:
        // default statements
}
HP Prime Programming Language (PPL)
CASE
    IF condition1 == expression THEN
        // statements
    END;
    IF condition2 == expression THEN
        // statements
    .
    .
    .
    END;
    IF conditionN == expression THEN
        // statements
    END;
    DEFAULT
        // default statements
END;

3. For-Next

For-next loop is used to iterate a set of statements based on a condition.

Prime Plus Language (P+)
for a = 0 ... 9 {
    // code
}
for a = 9 down ... 0 step b {
    // code
}
HP Prime Programming Language (PPL)
FOR a = 0 TO 9 DO
    // code
END;
FOR a = 9 DOWNTO 0 STEP b DO
    // code
END;

4. While-Do

While-do is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

note:
Also valid PPL code.
Prime Plus Language (P+)
while condition {
    // code
}
HP Prime Programming Language (PPL)
WHILE condition DO
    // code
END;

5. Repeat-Until

Repeat-until is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.

note:
Also valid PPL code.
Prime Plus Language (P+)
repeat
    // code
until condition
HP Prime Programming Language (PPL)
REPEAT
    // code
UNTIL condition

6. Function

Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity. Function gets run only when it is called.

Prime Plus Language (P+)
var var1, auto:var2; // global variables
var3; // var is optional for global variables NOTE 'auto' not supported!

#define NUM_ZERO	0

export MAINPRG()
@begin
    // code
    return NUM_ZERO;
@end

#include "include.pp"

SUBROUTINE()
@begin
    var var4; // local variable only : SUBROUTINE()
    var4 = var3+var2-var1;
@end
include.pp
SUBROUTINE_FILE()
@begin
    return !NUM_ZERO;
@end
HP Prime Programming Language (PPL)
LOCAL var1, v1; // global variables
var3; // var is optional for global variables NOTE 'auto' not supported!
EXPORT MAINPRG()
BEGIN
    // code
    RETURN 0;
END;
SUBROUTINE_FILE()
BEGIN
    RETURN NOT 0;
END;
SUBROUTINE()
BEGIN
    LOCAL var4; // local variable only : SUBROUTINE()
    var4 = var3+v1-var1;
END;

7. Double-Identity

Variables possess the capability to be linked to an alternate name, enabling the use of longer, more meaningful names while still retaining shorter versions. This approach proves advantageous as it minimizes the storage footprint in the hpprgm file format.

Prime Plus Language (P+)
fnt:longFunctionName(a:alpha)
@begin
    var i:index := 1;
    var v:variableName := 2;
    PRINT(alpha);
    PRINT(index);
    PRINT(variableName);
@end
HP Prime Programming Language (PPL)
fnt(a)
BEGIN
    LOCAL i:= 1;
    LOCAL v:= 2;
    PRINT(a);
    PRINT(i);
    PRINT(v);
END;

8. Set-As

These bear similarities to #define, yet differ in that they adopt a prefix-suffix structure. This unique arrangement facilitates the efficient organization of aliases to functions into various categories.

Prime Plus Language (P+)
@set myFn::LongFunctionName as SUBROUTINE
SUBROUTINE(a:alpha)
@begin
    PRINT(alpha);
@end

@start
    myFn::LongFunctionName(1);
@end
HP Prime Programming Language (PPL)
SUBROUTINE(a)
BEGIN
    PRINT(a);
END;
EXPORT START()
BEGIN
    SUBROUTINE(1);
END;

9. Data-As

These bear similarities to #define, yet differ in that they asign an name to the data contents of a given file. This unique arrangement facilitates the ability of injecting file data into a LIST.

Prime Plus Language (P+)
#include <prime>
@data bin as "file.bin"
@start
   pixel::GROB::dim(G1, 4, 4, `bin`);
   pixel::blit(0, 0, G1);
   fn::freeze;
@end
HP Prime Programming Language (PPL)
EXPORT START()
BEGIN
   DIMGROB_P(G1, 4, 4, {
#0123456789ABCDEF:64h,#FEDCBA9876543210:64h,#0123456776543210:64h,#0123321000112233:64h});
   BLIT_P(0, 0, G1);
   FREEZE;
END;

10. Auto

The challenge posed by lengthy variables, functions, and parameter names lies in the significant increase in file footprint. While adopting shorter names may mitigate this concern, it concurrently introduces complexity in code comprehension and maintenance. The 'auto' feature effectively addresses this quandary by permitting the utilization of extended names. During processing, these extended names are automatically substituted with abbreviated counterparts, thereby preserving the manageability and comprehensibility of your source code.

Prime Plus Language (P+)
auto:longFunctionName(auto:parameter)
@begin
    var index:longIndex := 1;
    var auto:shortIndex := 2;
    PRINT(longIndex);
    PRINT(shortIndex);
    PRINT(parameter);
@end
HP Prime Programming Language (PPL)
fn1(p1)
BEGIN
    LOCAL index:= 1;
    LOCAL v1:= 2;
    PRINT(index);
    PRINT(v1);
    PRINT(p1);
END;
1.3.2

11. Classes

Creates a collection of subroutines and global variables as methods and properties, inherited by an object.

Prime Plus Language (P+)
#include <prime>

@class MyClass
- myMethod()
{
    io::print("Hello World");
}
@end
HP Prime Programming Language (PPL)
// No PPL Code Generated
1.3.2

11. Object

Wraps a collection of subroutines and global variables as methods and properties, accessed via the object name.

Prime Plus Language (P+)
#include <prime>
#include "class.pp"

@object MyObject : MyClass
- print(t:text)
{
    self.myMethod();
    io::print(text);
}
@end

@start
    [MyObject print:"Objective-C Style"];
    MyObject::print("Namespace Style");
    fn::freeze;
@end
HP Prime Programming Language (PPL)
o1m1()
BEGIN
    PRINT("Hello World");
END;
o1m2(t)
BEGIN
    o1m1();
    PRINT(t);
END;
EXPORT START()
BEGIN
    o1m2("Objective-C Style");
    o1m2("Namespace Style");
    FREEZE;
END;

12. Const

Constants, these will become just normal variables in PPL and if your P+ code trys to change a constant it will simple give a warning.