Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forumswhere to define a variable?
https://www.eclipse.org/forums/index.php/mv/msg/424656/968648/#msg_968648
In an atl rule, where can i define a variable ?
I defined in "using block", but it looks like a constant.
using{
n:Integer=1;
}
Thanks
K]]>Kosala Yapa2012-11-02T16:34:12-00:00Re: where to define a variable?
https://www.eclipse.org/forums/index.php/mv/msg/424656/971999/#msg_971999
For variables which are local to a given rule, the "using" section is effectively the good option: http://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Language#Local_variables_section.
FYI, for variables global to a whole transformation, you should rather use helper attributes: http://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Language#Attributes.
However, by using the declarative constructs and OCL iterators instead, it could be very likely that you don't actually need such variables.
Best regards,
Hugo]]>Hugo Bruneliere2012-11-05T09:21:46-00:00Re: where to define a variable?
https://www.eclipse.org/forums/index.php/mv/msg/424656/972418/#msg_972418
Thanks a mil for your reply.
I defined following two integer variables and do block in a lazy rule and later changed in a for loop.
problem: I always get num as 0. Can you see the error?
using{
num:Integer=0;
index:Integer=1;
}
do{
for(m2 in a.getModules())
{
num = m2.getSlotValue().toInteger()-index;
if ( num<>0)
{
p.Modules<-thisModule.rule_getNullModule(m2);
}
else
{
p.Modules<-thisModule.rule_getModule(m2);
}
index = index+1;
}-- for all Modules
}--end do
Thanks.
K]]>Kosala Yapa2012-11-05T16:05:16-00:00Re: where to define a variable?
https://www.eclipse.org/forums/index.php/mv/msg/424656/972498/#msg_972498
do sections have to performed using the <- operator and not the = one.