Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Model-to-Model Transformation » ATL - if expression error
ATL - if expression error [message #874038] Sat, 19 May 2012 20:27 Go to next message
Fernanda R.F. is currently offline Fernanda R.F.Friend
Messages: 64
Registered: May 2012
Member
Hi,

I'm trying to use an if expression with more than one action inside it, like:

if(aPerson.gender = #male) {
thisModule.fullName <- 'Mr. ' + aPerson.name + ' ' + aPerson.surname;
}
else {
if(aPerson.isSingle) {
thisModule.fullName <- 'Miss ' + aPerson.name;
thisModule.surname <- aPerson.surname;
}
else {
thisModule.fullName <- 'Mrs. ' + aPerson.name;
thisModule.surname <- aPerson.marriedTo.surname;
}
thisModule.fullName <- thisModule.fullName + ' ' + thisModule.surname;
}


However, when I put " {" after if condition, is being shown the following error:
mismatched input '{' expecting 'then'


How can I use more than one action into if expression?

Thanks
Re: ATL - if expression error [message #874583 is a reply to message #874038] Mon, 21 May 2012 07:33 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 523
Registered: July 2009
Senior Member
There are 2 different kind of if statements.
The construction you are using here is only usable in the imperative code sections ("do" section of a rule).
The other construction is an OCL one :
if {cond} then {thenstmt} else {elsestmt} endif
This construction must always return a result so you won't be able to affect variables here, you should use a helper for your case.
Re: ATL - if expression error [message #876461 is a reply to message #874583] Thu, 24 May 2012 16:44 Go to previous message
Fernanda R.F. is currently offline Fernanda R.F.Friend
Messages: 64
Registered: May 2012
Member
Thanks Sylvain!
Now it's working!
=D
Previous Topic:Merging multiple Instance Models
Next Topic:[ATL] how can I the filename of the source model?
Goto Forum:
  


Current Time: Fri Dec 19 07:21:17 GMT 2014

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

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