Syntaxhelp1.If-ElseWheneveryouwanttoperformasetofoperationsbasedonaconditionIf-Elseisused.PrimePlusLanguage(P+)ifexpressionthen// code for 'expression' is trueelse// code for 'expression' is falseendif;ifexpression{// code for 'expression' is true}HPPrimeProgrammingLanguage(PPL)IFexpressionTHEN// code for 'expression' is trueELSE// code for 'expression' is falseEND;IFexpressionTHEN// code for 'expression' is trueEND;2.Switch-CaseSwitch-caseisanalternativetoIf-Else-Ifladder.PrimePlusLanguage(P+)switchexpressioncasecondition1// statementsend;casecondition2// statementsend;...caseconditionN:// statementsend;default// default statementsend;HPPrimeProgrammingLanguage(PPL)CASEIFexpression1THEN// statementsEND;IFexpression2THEN// statementsEND;...IFexpressionNTHEN// statementsEND;DEFAULT// optional // statementsEND;3.For-NextFor-nextloopisusedtoiterateasetofstatementsbasedonacondition.PrimePlusLanguage(P+)fora=0...9{// code}fora=9down...0stepb{// code}forbfrom0...9step1do// codenext;forcfrom9down...0step2do// codenext;HPPrimeProgrammingLanguage(PPL)FORaFROM0TO9DO// codeEND;FORaFROM9DOWNTO0STEPbDO// codeEND;FORbFROM0TO9STEP1DO// codeEND;FORcFROM9DOWNTO0STEP2DO// codeEND;4.While-DoWhile-doisalsousedtoiterateasetofstatementsbasedonacondition.Usuallywhileispreferredwhennumberofiterationsarenotknowninadvance.note:AlsovalidPPLcode.PrimePlusLanguage(P+)whileconditiondo// codeend;whilecondition{// code}HPPrimeProgrammingLanguage(PPL)WHILEconditionDO// codeEND;5.Repeat-UntilRepeat-untilisalsousedtoiterateasetofstatementsbasedonacondition.Itismostlyusedwhenyouneedtoexecutethestatementsatleastonce.note:AlsovalidPPLcode.PrimePlusLanguage(P+)repeat// codeuntilconditionHPPrimeProgrammingLanguage(PPL)REPEAT// codeUNTILcondition6.FunctionFunctionisasub-routinewhichcontainssetofstatements.Usuallyfunctionsarewrittenwhenmultiplecallsarerequiredtosamesetofstatementswhichincreasesre-usuabilityandmodularity.Functiongetsrunonlywhenitiscalled.PrimePlusLanguage(P+)varvar1,var2;// global variablesvar3;// var is optional for global variablesexportMAINPRG()@begin// codealiasNUM_ZERO0returnNUM_ZERO;@endembedinclude.ppSUBROUTINE()@beginvarvar4;// local variable only : SUBROUTINE()var4=var3+var2-var1;@endinclude.ppSUBROUTINE_FILE()@beginreturn!NUM_ZERO;@endHPPrimeProgrammingLanguage(PPL)LOCALvar1,var2;// global variablesvar3;// LOCAL is optional for global variablesEXPORTMAINPRG()BEGIN// codereturn0;END;SUBROUTINE_FILE()BEGINreturnNOT0;END;SUBROUTINE()BEGINLOCALvar4;// local variable only : SUBROUTINE()var4:=var3+var2-var1;END;7.Double-IdentityNow,variableswithnamesfroma-zhavethecapabilitytobeassociatedwithanalternativeidentity,allowingforamoremeaningfulnamewhilestillmaintainingasingle-charactername.Thisapproachisadvantageousasitrequiresonlytwobytesofstorageinthehpprgmfileformat.PrimePlusLanguage(P+)SUBROUTINE(a:alpha)@beginvari:index=1;var?:auto_variable_name=2;PRINT([alpha]);PRINT([index]);PRINT([auto_variable_name]);@end// All Double Identities PurgedHPPrimeProgrammingLanguage(PPL)SUBROUTINE(a)BEGINLOCALi:=1;LOCALb:=2;PRINT(a);PRINT(i);PRINT(b);END;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A continuación se muestra como se codifica en la calculadora HP_PRIME, que puede servir para mejorar como se codiifca en PseInt
Fuente:
https://www.insoft.uk/prime-plus.php