Skip to main content



      Home
Home » Modeling » Model-to-Model Transformation » ATL - if expression error
ATL - if expression error [message #874038] Sat, 19 May 2012 16:27 Go to next message
Eclipse UserFriend
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 03:33 Go to previous messageGo to next message
Eclipse UserFriend
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 12:44 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 13:26:02 EDT 2025

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

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

Back to the top