Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Counter is never incremented in a matched rule
Counter is never incremented in a matched rule [message #1760906] Thu, 04 May 2017 08:59 Go to next message
im hello world is currently offline im hello worldFriend
Messages: 44
Registered: February 2017
Member
Hi ,
i created a counter (next to several other counters)
helper def: counter2: Integer =0;

and i tried to increment it in a rule
L
ocation: upp!Location (
			id <- 'id' + thisModule.counter2 ,
)
(..........)

do { thisModule.counter2<- thisModule.counter2 + 1 ;
				}
}

the problem is that other counters are incremented, but this one no!
i don't see where is the error.
any help please.
Thank you.

[Updated on: Thu, 04 May 2017 09:01]

Report message to a moderator

Re: Counter is never incremented in a matched rule [message #1760912 is a reply to message #1760906] Thu, 04 May 2017 09:34 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 552
Registered: July 2009
Senior Member
The imperative part (do) of a matched rule is only executed after all the declarative parts (to) are executed.
So your counter is incremented but that's already too late.
Re: Counter is never incremented in a matched rule [message #1760915 is a reply to message #1760912] Thu, 04 May 2017 10:02 Go to previous messageGo to next message
im hello world is currently offline im hello worldFriend
Messages: 44
Registered: February 2017
Member
Hi,
The imperative part (do) of a matched rule was called after all the declarative parts (to) .
i just forgot to put the 'to', sorry
I made some modifications.

from (......)
to Location: upp!Location (
			id <- 'id' + thisModule.counter2 ,
)
(..........)

do { thisModule.counter2<- thisModule.counter2 + 1 ;
				}
}


regards
Re: Counter is never incremented in a matched rule [message #1760929 is a reply to message #1760915] Thu, 04 May 2017 12:12 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 552
Registered: July 2009
Senior Member
What I meant was for the whole transformation so it runs the "to" part of all the rules and then the "do" parts of all the rules also.
So your "do" code is launched once all the "id" attributes are already populated (all with the same value then).
Re: Counter is never incremented in a matched rule [message #1760971 is a reply to message #1760929] Thu, 04 May 2017 18:37 Go to previous message
im hello world is currently offline im hello worldFriend
Messages: 44
Registered: February 2017
Member
Thank you.
i have in my transformation many rules and lazy rules, so , do i increment the counter in each matched rule? and for the lazy rule, is it the same case? because i have a counter incremented in a lazy rule , but this counter is still incremented in a matched rule when i call that lazy Rule, when,in the matched rule i just need a reference to the id created in that lazy rule.

[Updated on: Thu, 04 May 2017 18:39]

Report message to a moderator

Previous Topic:ATL installation with GIT repository
Next Topic:Error while trying to add a breakpoint to debug an ATL project
Goto Forum:
  


Current Time: Mon Jul 16 20:08:21 GMT 2018

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

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

Back to the top