Proteus Plus

Proteus syntax does not include operators: this approach has many advantages (greater speed and precision), but sometimes lead to confusion when doing a lot of maths.

For this reason, we have created a Proteus-based metalanguage, which has almost the same syntax of Proteus but adds a few exceptions, introduced to accomodate many useful operators.

Obviously, when adding operators we need to use parenthesis, to tell Proteus the order in which operations must be performed.

Proteus Plus programs should always keep the extension .prp; you don't need another interpreter to run them: just run the script prp.prt, which will convert them to Proteus scripts, which can be run by the standard interpreter.

These are the most significative differences introduced by Proteus Plus:

e.g.
SWITCH s STREQ()

This is the list of allowed operators and the corresponding functions, ordered by priority:

(maximum priority)

( )    grouping operator

[Unary operators]

! NOT
~ NNOT
++ INC
-- DEC
+ ABS
- NEG

[Binary operators]

* MUL
/ FDIV
\ DIV
% MOD
^^ POW
+ ADD
; STRCAT
- SUB
<< SHIFTLT
>> SHIFTRT
< LT
<= LE
> GT
>= GE
$ IN
== EQ
= EQ
!= NEQ
$= STREQ
!$ STRNEQ
& NAND
^ NXOR
| NOR
&& AND
|| OR
:= ISET
*= MUL@
/= FDIV@
\= DIV@
%= MOD@
+= ADD@
-= SUB@
&= NAND@
^= NXOR@
|= NOR@
<<= SHIFTLT@
>>= SHIFTRT@

(minimum priority)

The syntax to invoke the converter from Proteus Plus to Proteus is the following:

proteus prp.prt source.prp [dest.prt | = [parameters..]]

If the parameter dest.prt is specified, the converted program will be saved to this file; if the character "=" takes its place, the program will be saved to a temporary file and run directly, using the optional specified parameters; the temporary file will be removed when the program ends. 

Example in Proteus Plus

FUNCTION PVSF(TEMP)

PRIF = 101325.0
T = TEMP + 273.16
Z = 273.16 / T
IF T < 273.16
  P1 = -9.096936 * (Z - 1)
  P2 = -3.56654 * LOG10(Z)
  P3 = 0.876817 * (1.0 - (1.0 / Z))
  P4 = -2.2195983
ELSE
  P1 = (10.79586 * (1.0 - Z)) - 2.2195983
  P2 = 5.02808 * LOG10(Z)
  A1 = -8.29692 * ((1.0 / Z) - 1.0)
  P3 = "1.5047E-04" * (1.0 - (10.0 ^^ A1))
  A2 = 4.76955 * (1.0 - Z)
  P4 = "0.42873E-03" * ((10.0 ^^ A2) - 1.0)
FI
SUM = P1 + P2 + P3 + P4
RETURN PRIF * (10 ^^ SUM)


FUNCTION WBFF(W, DB)

WB1 = DB
REPEAT
  WS1 = XSAT(WB1)
  W1 = ( (WS1 * (2501 - (2.364 * WB1))) + (1.006 * (WB1 - DB)) ) / (2501 + (1.83 * DB) - (4.194 * WB1))
  Y1 = W - W1
  IF ABS(Y1) <= 0.00003
    RETURN WB1
  FI
  IF Y1 = 0
    RETURN WB1
  FI
  IF Y1 > 0
    WB1 = WB1 + 0.5
    CONTINUE
  FI
  REPEAT
    WB2 = WB1 - 1
    WS2 = XSAT(WB2)  
    W2 = ( (WS2 * (2501 - (2.364 * WB2))) + (1.006 * (WB2 - DB)) ) / (2501 + (1.83 * DB) - (4.194 * WB2))
    Y2 = W - W2
    IF ABS(Y2) <= 0.00003
      RETURN WB2
    FI
    IF Y2 = 0
      RETURN WB2
    FI
    IF (Y1 * Y2) < 0
      Z = ABS(Y1 / Y2)
      RETURN ((WB2 * Z) + WB1) / (Z + 1)
    FI
    IF (Y1 * Y2) = 0
      IF Y1 != 0
        RETURN WB2
      ELSE
        RETURN WB1
      FI
    ELSE
      WB1 = WB2
      Y1 = Y2
    FI
  UNTIL 0
UNTIL 0
RETURN


FUNCTION PSDBRH(@DB, @WB, @DP, @PB, @PV, @W, @H, @V, @RH)

IF RH = 0
  RH = 0.001
FI
IF (RH < 0.001) || (RH > 100)
  CONSOLELN ""
  CONSOLELN "ERROR IN PSDBRH : DB=" ; PFORMAT("6.2f", DB) ; "  RH=" ; PFORMAT("6.2f", RH)
  CONSOLELN "Relative humidity not compatible"
  ABORT 0
FI
PVS = PVSF(DB)
X = RH - 100.0
IF ABS(X) <= 0.09
  RH = 100.0
FI
PV = (RH / 100.0) * PVS
W = (0.62198 * PV) / (PB - PV)
V = (8314.32 / 28.9645) * (DB + 273.16) * (1.0 + (1.6078 * W)) / PB
H = (DB * 1.006) + ((2501 + (1.83 * DB)) * W)
DP = DPF(PV)
WB = WBFF(W, DB)
RETURN


FUNCTION PSDBW(@DB, @WB, @DP, @PB, @PV, @W, @H, @V, @RH)

IF W = 0
  W = "1.E-07"
FI
IF W < "1.E-07"
  CONSOLELN ""
  CONSOLELN "ERROR IN PSDBW : DB=" ; PFORMAT("6.2f", DB) ; "  H=" ; PFORMAT("10.3e", W)
  CONSOLELN "Specific humidity not compatible"
  ABORT 0
FI
XS = 0.62198 * PVSF(DB) / (PB - PVSF(DB))
IF W > XS
  CONSOLELN ""
  CONSOLELN "ERROR IN PSDBW : DB=" ; PFORMAT("6.2f", DB) ; "  H=" ; PFORMAT("10.3e", W)
  CONSOLELN "Specific humidity not compatible"
  ABORT 0
FI
H = 1.006 * DB + (2501.0 + 1.83 * DB) * W
V = 8314.32 / 28.9645 * (DB + 273.16) * (1.0 + 1.6078 * W) / PB
PV = W * PB / (0.62198 + W)
RH = PV / PVSF(DB) * 100.0
WB = WBFF(W, DB)
DP = DPF(PV)
RETURN

Code translated by prp.prt to standard Proteus

FUNCTION PVSF(TEMP)

PRIF = 101325.0
T = ADD(TEMP,273.16)
Z = FDIV(273.16,T)
IF LT(T,273.16)
  P1 = MUL(-9.096936,SUB(Z,1))
  P2 = MUL(-3.56654,LOG10(Z))
  P3 = MUL(0.876817,SUB(1.0,FDIV(1.0,Z)))
  P4 = -2.2195983
ELSE
  P1 = SUB(MUL(10.79586,SUB(1.0,Z)),2.2195983)
  P2 = MUL(5.02808,LOG10(Z))
  A1 = MUL(-8.29692,SUB(FDIV(1.0,Z),1.0))
  P3 = MUL("1.5047E-04",SUB(1.0,POW(10.0,A1)))
  A2 = MUL(4.76955,SUB(1.0,Z))
  P4 = MUL("0.42873E-03",SUB(POW(10.0,A2),1.0))
FI
SUM = ADD(ADD(ADD(P1,P2),P3),P4)
RETURN MUL(PRIF,POW(10,SUM))


FUNCTION WBFF(W, DB)

WB1 = DB
REPEAT
  WS1 = XSAT(WB1)
  W1 = FDIV(ADD(MUL(WS1,SUB(2501,MUL(2.364,WB1))),MUL(1.006,SUB(WB1,DB))),SUB(ADD(2501,MUL(1.83,DB)),MUL(4.194,WB1)))
  Y1 = SUB(W,W1)
  IF LE(ABS(Y1),0.00003)
    RETURN WB1
  FI
  IF EQ(Y1,0)
    RETURN WB1
  FI
  IF GT(Y1,0)
    WB1 = ADD(WB1,0.5)
    CONTINUE
  FI
  REPEAT
    WB2 = SUB(WB1,1)
    WS2 = XSAT(WB2)
    W2 = FDIV(ADD(MUL(WS2,SUB(2501,MUL(2.364,WB2))),MUL(1.006,SUB(WB2,DB))),SUB(ADD(2501,MUL(1.83,DB)),MUL(4.194,WB2)))
    Y2 = SUB(W,W2)
    IF LE(ABS(Y2),0.00003)
      RETURN WB2
    FI
    IF EQ(Y2,0)
      RETURN WB2
    FI
    IF LT(MUL(Y1,Y2),0)
      Z = ABS(FDIV(Y1,Y2))
      RETURN FDIV(ADD(MUL(WB2,Z),WB1),ADD(Z,1))
    FI
    IF EQ(MUL(Y1,Y2),0)
      IF NEQ(Y1,0)
        RETURN WB2
      ELSE
        RETURN WB1
      FI
    ELSE
      WB1 = WB2
      Y1 = Y2
    FI
  UNTIL 0
UNTIL 0
RETURN


FUNCTION PSDBRH(@DB, @WB, @DP, @PB, @PV, @W, @H, @V, @RH)

IF EQ(RH,0)
  RH = 0.001
FI
IF OR(LT(RH,0.001),GT(RH,100))
  CONSOLELN ""
  CONSOLELN "ERROR IN PSDBRH : DB=" PFORMAT("6.2f",DB) "  RH=" PFORMAT("6.2f",RH)
  CONSOLELN "Relative humidity not compatible"
  ABORT 0
FI
PVS = PVSF(DB)
X = SUB(RH,100.0)
IF LE(ABS(X),0.09)
  RH = 100.0
FI
PV = MUL(FDIV(RH,100.0),PVS)
W = FDIV(MUL(0.62198,PV),SUB(PB,PV))
V = FDIV(MUL(MUL(FDIV(8314.32,28.9645),ADD(DB,273.16)),ADD(1.0,MUL(1.6078,W))),PB)
H = ADD(MUL(DB,1.006),MUL(ADD(2501,MUL(1.83,DB)),W))
DP = DPF(PV)
WB = WBFF(W,DB)
RETURN


FUNCTION PSDBW(@DB, @WB, @DP, @PB, @PV, @W, @H, @V, @RH)

IF EQ(W,0)
  W = "1.E-07"
FI
IF LT(W,"1.E-07")
  CONSOLELN ""
  CONSOLELN "ERROR IN PSDBW : DB=" PFORMAT("6.2f",DB) "  H=" PFORMAT("10.3e",W)
  CONSOLELN "Specific humidity not compatible"
  ABORT 0
FI
XS = FDIV(MUL(0.62198,PVSF(DB)),SUB(PB,PVSF(DB)))
IF GT(W,XS)
  CONSOLELN ""
  CONSOLELN "ERROR IN PSDBW : DB=" PFORMAT("6.2f",DB) "  H=" PFORMAT("10.3e",W)
  CONSOLELN "Specific humidity not compatible"
  ABORT 0
FI
H = ADD(MUL(1.006,DB),MUL(ADD(2501.0,MUL(1.83,DB)),W))
V = FDIV(MUL(MUL(FDIV(8314.32,28.9645),ADD(DB,273.16)),ADD(1.0,MUL(1.6078,W))),PB)
PV = FDIV(MUL(W,PB),ADD(0.62198,W))
RH = MUL(FDIV(PV,PVSF(DB)),100.0)
WB = WBFF(W,DB)
DP = DPF(PV)
RETURN
Start of page Next topic Previous topic Contents Index
Midnight Lake iPhone Case Black Women Shoes Black Flat Shoes Leather Flats Black Patent Ballerinas Black Ballet Shoes Casual Shoes Black Shoes Women Balle Record Player Cufflinks Best iPhone XR Clear Cases iPhone XS/XS Max Leather Cases Sale Best iPhone 8/8 Plus Silicone Cases iPhone 7/7 Plus Cases & Screen Protector New Cases For iPhone 6/6 Plus iPhone 8 Case Sale iPhone Xr Case Online iPhone 7 Case UK Online iPhone X Case UK Sale iPhone X Case Deals iPhone Xs Case New Case For iPhone Xr UK Online Case For iPhone 8 UK Outlet Fashion Silver Cufflinks For Men Best Mens Cufflinks Outlet Online The Gold Cufflinks Shop Online Cheap Shirt Cufflinks On Sale Nice Wedding Cufflinks UK Online Top Black Cufflinks UK Online Mens Cufflinks Online Silver Cufflinks For Men Men Cufflinks UK Sale Gold Cufflinks UK Online Gold Cufflinks UK Silver Cufflinks UK Shirt Cufflinks Discount Online Mens Cufflinks Deals & Sales Girls Shoes For Dance Fashion Ballet Dance Shoes Best Ballet Flats Shoes UK Online Cheap Ballet Pointe Shoes UK Online Best Ballet Shoes Outlet Best Dance Shoes Sale Cheap Ballet Flats Sale UK Best Pointe Shoes Online UK Ballet Dance Shoes UK Shoes For Dance UK Best Ballet Slippers Shop Best Yoga Shoes Hotsell