Post Reply 
Support for comments /* ... */
02-24-2017, 05:36 PM (This post was last modified: 02-24-2017 06:05 PM by compsystems.)
Post: #1
Support for comments /* ... */
Hello

One way to better visualize a code, where a function has several arguments (for example input( arg1, arg2, ..., argn), is to write each argument in a separate line

input
(
arg1,
arg2,
...,
argn
);

But if you want to comment with // the code generates error, because the comment covers until the end of the sentence (; ), for this we need comments of the form / * * /

PHP Code:
export testInputList()
begin
    local a
bc;
    
local resetVAL_aresetVAL_bresetVAL_c;
    
local initVAL_ainitVAL_binitVAL_c;

    
initVAL_a:={1}; initVAL_b:={2}; initVAL_c:={3}; 
    
resetVAL_a:={}; resetVAL_b:={}; resetVAL_c:={}; 
    
    
local ObjectType_AllAllowed := -1;
    
local ObjectType_Real := 0;
    
local ObjectType_Integer := 1;
    
local ObjectType_String := 2;  
    
local ObjectType_Complex := 3;  
    
local ObjectType_Matrix := 4;
    
local ObjectType_List := 6;
    
local ObjectType_Function := 8;  
    
local ObjectType_Unit := 9;  
    
local ObjectType_CAS := 14;

    
local ObjectType := ObjectType_List;
    
local title;

    case
        if 
ObjectType == -1 then title:="Type Allow: "+"Alls" end;
        if 
ObjectType == 0 then title:="Type Allow: "+"Real" end;
        if 
ObjectType == 1 then title:="Type Allow: "+"Integer" end;
        if 
ObjectType == 2 then title:="Type Allow: "+"String" end;  
        if 
ObjectType == 3 then title:="Type Allow: "+"Complex" end;  
        if 
ObjectType == 4 then title:="Type Allow: "+"Matrix" end;
        if 
ObjectType == 6 then title:="Type Allow: "+"List" end;
        if 
ObjectType == 8 then title:="Type Allow: "+"Function" end;  
        if 
ObjectType == 9 then title:="Type Allow: "+"Unit" end;  
        if 
ObjectType == 14 then title:="Type Allow: "+"CAS" end;
     default
        
title:="Type Allow: "+"?"
     
end;

    
local ok := 1;
    
local cancel := 0;
    
local keyPressedOnMenu := 0;
    
keyPressedOnMenu := input 
    
(  
        { 
         {
a, [ObjectType] }, 
         {
b, [ObjectType] },
         {
c, [ObjectType] }

        }, 
        
title,
        { 
"label_a""label_b","label_c" }, 
        { 
"help_a""help_b""help_c" },           
        { 
resetVAL_aresetVAL_bresetVAL_c }, 
        { 
initVAL_ainitVAL_binitVAL_c 
    );
    if 
keyPressedOnMenu == ok then
        
return ({abc});  
    else
        return 
"Done";
    
end;
end

Successful compilation
But not with

PHP Code:
INPUT
(   
       ...    
       { 
"help_a""help_b""help_c" },           
        
//{ resetVAL_a, resetVAL_b, resetVAL_c }, 
       //{ initVAL_a, initVAL_b, initVAL_c } 
); // end input 

The problem would be solved in the following way

PHP Code:
INPUT
(   
       ...    
       { 
"help_a""help_b""help_c" },           
        
/* { resetVAL_a, resetVAL_b, resetVAL_c },  */
        /* { initVAL_a, initVAL_b, initVAL_c } */
); 
Find all posts by this user
Quote this message in a reply
02-24-2017, 07:51 PM
Post: #2
RE: Support for comments /* ... */
(02-24-2017 05:36 PM)compsystems Wrote:  Hello

One way to better visualize a code, where a function has several arguments (for example input( arg1, arg2, ..., argn), is to write each argument in a separate line

input
(
arg1,
arg2,
...,
argn
);

But if you want to comment with // the code generates error, because the comment covers until the end of the sentence (; ), for this we need comments of the form / * * /

PHP Code:
export testInputList()
begin
    local a
bc;
    
local resetVAL_aresetVAL_bresetVAL_c;
    
local initVAL_ainitVAL_binitVAL_c;

    
initVAL_a:={1}; initVAL_b:={2}; initVAL_c:={3}; 
    
resetVAL_a:={}; resetVAL_b:={}; resetVAL_c:={}; 
    
    
local ObjectType_AllAllowed := -1;
    
local ObjectType_Real := 0;
    
local ObjectType_Integer := 1;
    
local ObjectType_String := 2;  
    
local ObjectType_Complex := 3;  
    
local ObjectType_Matrix := 4;
    
local ObjectType_List := 6;
    
local ObjectType_Function := 8;  
    
local ObjectType_Unit := 9;  
    
local ObjectType_CAS := 14;

    
local ObjectType := ObjectType_List;
    
local title;

    case
        if 
ObjectType == -1 then title:="Type Allow: "+"Alls" end;
        if 
ObjectType == 0 then title:="Type Allow: "+"Real" end;
        if 
ObjectType == 1 then title:="Type Allow: "+"Integer" end;
        if 
ObjectType == 2 then title:="Type Allow: "+"String" end;  
        if 
ObjectType == 3 then title:="Type Allow: "+"Complex" end;  
        if 
ObjectType == 4 then title:="Type Allow: "+"Matrix" end;
        if 
ObjectType == 6 then title:="Type Allow: "+"List" end;
        if 
ObjectType == 8 then title:="Type Allow: "+"Function" end;  
        if 
ObjectType == 9 then title:="Type Allow: "+"Unit" end;  
        if 
ObjectType == 14 then title:="Type Allow: "+"CAS" end;
     default
        
title:="Type Allow: "+"?"
     
end;

    
local ok := 1;
    
local cancel := 0;
    
local keyPressedOnMenu := 0;
    
keyPressedOnMenu := input 
    
(  
        { 
         {
a, [ObjectType] }, 
         {
b, [ObjectType] },
         {
c, [ObjectType] }

        }, 
        
title,
        { 
"label_a""label_b","label_c" }, 
        { 
"help_a""help_b""help_c" },           
        { 
resetVAL_aresetVAL_bresetVAL_c }, 
        { 
initVAL_ainitVAL_binitVAL_c 
    );
    if 
keyPressedOnMenu == ok then
        
return ({abc});  
    else
        return 
"Done";
    
end;
end

Successful compilation
But not with

PHP Code:
INPUT
(   
       ...    
       { 
"help_a""help_b""help_c" },           
        
//{ resetVAL_a, resetVAL_b, resetVAL_c }, 
       //{ initVAL_a, initVAL_b, initVAL_c } 
); // end input 

The problem would be solved in the following way

PHP Code:
INPUT
(   
       ...    
       { 
"help_a""help_b""help_c" },           
        
/* { resetVAL_a, resetVAL_b, resetVAL_c },  */
        /* { initVAL_a, initVAL_b, initVAL_c } */
); 

Would the following be equivalent?

PHP Code:
INPUT
(   
       ...    
       { 
"help_a""help_b""help_c" },           
        
/* { resetVAL_a, resetVAL_b, resetVAL_c },
            { initVAL_a, initVAL_b, initVAL_c } */
); 

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
02-24-2017, 07:58 PM
Post: #3
RE: Support for comments /* ... */
(02-24-2017 07:51 PM)toml_12953 Wrote:  The problem would be solved in the following way

PHP Code:
INPUT
(   
       ...    
       { 
"help_a""help_b""help_c" },           
        
/* { resetVAL_a, resetVAL_b, resetVAL_c },  */
        /* { initVAL_a, initVAL_b, initVAL_c } */
); 


Would the following be equivalent?

PHP Code:
INPUT
(   
       ...    
       { 
"help_a""help_b""help_c" },           
        
/* { resetVAL_a, resetVAL_b, resetVAL_c },
            { initVAL_a, initVAL_b, initVAL_c } */
); 

Yes but the compiler does not allow this type of comments = (
Find all posts by this user
Quote this message in a reply
02-25-2017, 12:25 AM (This post was last modified: 02-25-2017 12:29 AM by StephenG1CMZ.)
Post: #4
RE: Support for comments /* ... */
Changing the compiler to allow // comments on each line would be helpful, particularly when you have a long list of data

PlanetDistance:={
0.2,//Mercury
0.4,//Venus
1//AU

}
I
For function parameters, I have always liked the OPTIONAL ADA syntax for readability and avoidance of getting parameters confused, although for my own code I could remember the parameter sequence anyway without needing it:

TIMED(HOURS, MINS, SECS)
Return 60* ((60*hours)+mins)+secs;
END
...

Timed(hours=3,mins=2);

Timed(secs=1,mins=2);//the prefixes mean you don't need to remember which parameter is 1st

Timed(1,2,3); // the xxxx= is optional

I could imagine that syntax being useful when using a portable device with a small Screen makes looking up parameters difficult.

An alternative would be to have a way to search for user procedures and parameters, either within the editor (Find...), or by lookup within Help.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
02-26-2017, 03:39 PM (This post was last modified: 02-26-2017 03:40 PM by compsystems.)
Post: #5
RE: Support for comments /* ... */
also, if in a future firmware version, it supports comments of the type,

You could directly copy the following sequence of steps (of this forum) to the history view

PHP Code:
expr1:=x^3;
rpnStr:="";
oper:="";
partn:="";
oper:=part(expr1,0); /*returns "^" */
parts:=part(expr1); /*returns 2 */
partJ:=1;
expr2:=part(expr1,partJ); /*returns x */
partn:=string(expr2); /*returns "x" */
rpnStr:=rpnStr partn/* returns "x" */
partJ:=2;
expr2:=part(expr1,partJ); /*returns 3 */
partn:=string(expr2); /*returns "3" */
rpnStr:=rpnStr " "/*returns "x " */
rpnStr:=rpnStr partn/*returns "x 3" */
rpnStr:=rpnStr " " oper/*returns "x 3 ^"  */ 

currently I have to suppress them =(

PHP Code:
expr1:=x^3;
rpnStr:="";
oper:="";
partn:="";
oper:=part(expr1,0); 
parts:=part(expr1);
partJ:=1;
expr2:=part(expr1,partJ); 
partn:=string(expr2);
rpnStr:=rpnStr partn;
partJ:=2;
expr2:=part(expr1,partJ); 
partn:=string(expr2);
rpnStr:=rpnStr " ";
rpnStr:=rpnStr partn
rpnStr:=rpnStr " " oper

PHP Code:
expr1:=x^3rpnStr:=""oper:=""partn:=""oper:=part(expr1,0); parts:=part(expr1); partJ:=1expr2:=part(expr1,partJ); partn:=string(expr2); rpnStr:=rpnStr partnpartJ:=2expr2:=part(expr1,partJ); partn:=string(expr2); rpnStr:=rpnStr " ";rpnStr:=rpnStr partnrpnStr:=rpnStr " " oper

I can not put comments between each sentence = (

[Image: hp_prime_convertToRPN_image00.png]
Find all posts by this user
Quote this message in a reply
02-26-2017, 04:24 PM
Post: #6
RE: Support for comments /* ... */
The problem is that to do more things with comments requires us to turn it into a 2 step compilation process, with creating duplicate text for step 2. Right now there is not a preprocessor, nor enough memory to really do so on the hardware. There are not plans to support additional commenting methods at the moment.
[/quote]

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)