Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » if expression
if expression [message #1758089] Thu, 23 March 2017 12:29 Go to next message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 328
Registered: July 2016
Senior Member
I have the below code, if I want to add one if condition before "if condition2" without else part what can I do?
if condition1
then
	exp1
else
       if condition2
       then
	        exp2
        else  
                exp3
      endif
endif;

if I do something like below, I have a syntax error("expected else").
if condition1
then
	exp1
else
       if extra condition
       then       if condition2
                        then
	                exp2
                        else  
                        exp3
                        endif
      endif
endif;

"extra condition" ensures that "condition2" is defined.


Member of MDSE Research Group
http://mdse.ui.ac.ir

[Updated on: Thu, 23 March 2017 12:36]

Report message to a moderator

Re: if expression [message #1758095 is a reply to message #1758089] Thu, 23 March 2017 13:55 Go to previous messageGo to next message
louis andia. is currently offline louis andia.Friend
Messages: 47
Registered: November 2016
Member
No you can't. You have to define what happen if your extra condition isn't true. So it will probably be that in your case:
if condition1
then
	exp1
else
       if extra condition
       then       if condition2
                        then
	                exp2
                        else  
                        exp3
                        endif
      else  
       exp3
      endif
endif;
Re: if expression [message #1758119 is a reply to message #1758095] Thu, 23 March 2017 17:06 Go to previous messageGo to next message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 328
Registered: July 2016
Senior Member
Thanks for your kind help. My "exp3" has also many "if-then-else" expressions, is there any other idea?

Member of MDSE Research Group
http://mdse.ui.ac.ir
Re: if expression [message #1758120 is a reply to message #1758119] Thu, 23 March 2017 17:12 Go to previous messageGo to next message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 328
Registered: July 2016
Senior Member
In imperative part, I do something like this:
helper def : a : Boolean= false;
thisModule.a <- cond 1;	
if (cond 2)
{
	thisModule.a <-  thisModule.a + cond 3;
}

if ( thisModule.a){
....
}

Is it true?


Member of MDSE Research Group
http://mdse.ui.ac.ir

[Updated on: Thu, 23 March 2017 19:46]

Report message to a moderator

Re: if expression [message #1758128 is a reply to message #1758120] Thu, 23 March 2017 18:33 Go to previous messageGo to next message
louis andia. is currently offline louis andia.Friend
Messages: 47
Registered: November 2016
Member
Your 'exp3' can be an helper to avoid code duplication.
Re: if expression [message #1758142 is a reply to message #1758128] Thu, 23 March 2017 19:44 Go to previous message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 328
Registered: July 2016
Senior Member
Thank you

Member of MDSE Research Group
http://mdse.ui.ac.ir
Previous Topic:[to delete]
Next Topic:second element of sequence
Goto Forum:
  


Current Time: Thu Apr 25 23:33:57 GMT 2024

Powered by FUDForum. Page generated in 0.03396 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top