06-05-2016, 10:45 PM
Hello
Within the program editor, why is not the WHEN, IFTE and ()? ITEM, on TMPLT/2:BRANCH menu?
Note: IFTE is not synonymous with WHEN or ()? cmds
WHEN cmd
test_whencmd_cas(true); [enter] returns true
test_whencmd_cas(false); [enter] returns false
purge(x); test_whencmd_cas(x); [enter] returns ((x)? true : false)
// if the test is symbolic, it returns
test_whencmd_cas(1); test_whencmd_cas(0); test_whencmd_cas(-1);
[enter] returns true,false,true
with (?) infix operator
test_questionmarkcmd_cas(1); test_questionmarkcmd_cas(0); test_questionmarkcmd_cas(-1);
[enter] returns true, false, true
test_questionmarcmd_cas(x); [enter] returns ((x)? true : false)
with IFTE cmd, the test must always return a numerical value
test_iftecmd_cas(1); test_iftecmd_cas(0); test_iftecmd_cas(-1);test_iftecmd_cas(true); test_iftecmd_cas(false);
[enter]
1,0,1,1,0
test_iftecmd_cas(x); [enter] IFTE(x,1,0)
ifte + := operator
ifte(true,(testvar1:=123),(testvar2:=456)); [enter] returns 123 ok [up] [up] [copy] [enter] ok
ifte(false,(testvar1:=123),(testvar2:=456)); [enter] returns 456 ok
purge(testvar1, testvar2);
ifte + => operator
(true)? (123=>testvar1): (456=>testvar2); [enter] returns 123 ok,
(false)? (123=>testvar1): (456=>testvar2); [enter] returns 456 ok, but [up] [up][copy] [enter]
"sto 123:testvar4 not allowed! Error: Bad Argument Type"
Cause of the problem: the parentheses are suppressed in the arguments (123=>testvar3) to 123=>testvar3, this means that it cannot be interpreted
purge(x);
test_questionmark2cmd_cas(x) [enter] returns 123, Why?
Within the program editor, why is not the WHEN, IFTE and ()? ITEM, on TMPLT/2:BRANCH menu?
Note: IFTE is not synonymous with WHEN or ()? cmds
WHEN cmd
PHP Code:
#cas
test_whencmd_cas(testvar):=
begin
return when( testvar, true, false );
end;
#end
test_whencmd_cas(true); [enter] returns true
test_whencmd_cas(false); [enter] returns false
purge(x); test_whencmd_cas(x); [enter] returns ((x)? true : false)
// if the test is symbolic, it returns
test_whencmd_cas(1); test_whencmd_cas(0); test_whencmd_cas(-1);
[enter] returns true,false,true
with (?) infix operator
PHP Code:
#cas
test_questionmarkcmd_cas(testvar):=
begin
return (testvar)? true:false;
end;
#end
test_questionmarkcmd_cas(1); test_questionmarkcmd_cas(0); test_questionmarkcmd_cas(-1);
[enter] returns true, false, true
test_questionmarcmd_cas(x); [enter] returns ((x)? true : false)
with IFTE cmd, the test must always return a numerical value
PHP Code:
#cas
test_iftecmd_cas(testvar):=
begin
return ifte( testvar, true, false );
end;
test_iftecmd_cas(1); test_iftecmd_cas(0); test_iftecmd_cas(-1);test_iftecmd_cas(true); test_iftecmd_cas(false);
[enter]
1,0,1,1,0
test_iftecmd_cas(x); [enter] IFTE(x,1,0)
ifte + := operator
ifte(true,(testvar1:=123),(testvar2:=456)); [enter] returns 123 ok [up] [up] [copy] [enter] ok
ifte(false,(testvar1:=123),(testvar2:=456)); [enter] returns 456 ok
purge(testvar1, testvar2);
ifte + => operator
(true)? (123=>testvar1): (456=>testvar2); [enter] returns 123 ok,
(false)? (123=>testvar1): (456=>testvar2); [enter] returns 456 ok, but [up] [up][copy] [enter]
"sto 123:testvar4 not allowed! Error: Bad Argument Type"
Cause of the problem: the parentheses are suppressed in the arguments (123=>testvar3) to 123=>testvar3, this means that it cannot be interpreted
PHP Code:
#cas
test_questionmark2cmd_cas(testvar):=
begin
return (true)? (123=>testvar1): (456=>testvar2);
end;
#end
test_questionmark2cmd_cas(x) [enter] returns 123, Why?