Support for comments /* ... */ - compsystems - 02-24-2017 05:36 PM
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, b, c; local resetVAL_a, resetVAL_b, resetVAL_c; local initVAL_a, initVAL_b, initVAL_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_a, resetVAL_b, resetVAL_c }, { initVAL_a, initVAL_b, initVAL_c } ); if keyPressedOnMenu == ok then return ({a, b, c}); 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 } */ );
RE: Support for comments /* ... */ - toml_12953 - 02-24-2017 07:51 PM
(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, b, c; local resetVAL_a, resetVAL_b, resetVAL_c; local initVAL_a, initVAL_b, initVAL_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_a, resetVAL_b, resetVAL_c }, { initVAL_a, initVAL_b, initVAL_c } ); if keyPressedOnMenu == ok then return ({a, b, c}); 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 } */ );
RE: Support for comments /* ... */ - compsystems - 02-24-2017 07:58 PM
(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 = (
RE: Support for comments /* ... */ - StephenG1CMZ - 02-25-2017 12:25 AM
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.
RE: Support for comments /* ... */ - compsystems - 02-26-2017 03:39 PM
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^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;
I can not put comments between each sentence = (
RE: Support for comments /* ... */ - Tim Wessman - 02-26-2017 04:24 PM
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]
|