Post Reply 
Missing "WHEN" "IFTE"and "()?" ITEMs
06-05-2016, 10:45 PM (This post was last modified: 05-06-2021 04:04 PM by compsystems.)
Post: #1
Missing "WHEN" "IFTE"and "()?" ITEMs
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

PHP Code:
#cas
test_whencmd_cas(testvar):=
begin
    
return whentestvartruefalse );
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 iftetestvartruefalse );
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 
purge(x);
test_questionmark2cmd_cas(x) [enter] returns 123, Why?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Missing "WHEN" "IFTE"and "()?" ITEMs - compsystems - 06-05-2016 10:45 PM
RE: missing "WHEN" ITEM - Wes Loewer - 06-06-2016, 06:52 AM



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