Lazy rule: problem with a counter [message #1760875] |
Wed, 03 May 2017 20:35 |
im hello world Messages: 44 Registered: February 2017 |
Member |
|
|
Hi,
I created a counter to increment the id of a LocReady:
helper def: counter: Integer =0;
lazy rule LocReady {
from
b: BP!Bo
to
locR: upp!Loc (
id <- 'id0' + thisModule.counter)
do {
thisModule.counter<- thisModule.counter+1;
}
and i have a rule in which i call my lazy rule 'LocReady'
rule xyz{
(...)
source: upp!Source (
ref <- thisModule.LocReady(b).refGetValue('id')),
tr: upp!tr(
source <- source)
}
i want to do a reference to the id of my LocReady in the rule xyz, the problem is with the counter, in the rule i notice that counter is always incremented(i get the id of locReady+1 and not the id. i note that i don't do an other incrementation in the rule
for example:
<locReady id="id09">
<tr>
<source id="id012">
what do you think the problem is?
thanks.
[Updated on: Thu, 04 May 2017 09:00] Report message to a moderator
|
|
|
|
|
Re: Lazy rule: problem with a counter [message #1763800 is a reply to message #1763657] |
Fri, 19 May 2017 20:53 |
|
I think your lazy rule returns the value of thisModule.counter rather than locR. Can you change your code as follows and try again:
lazy rule LocReady {
from
b: BP!Bo
to
locR: upp!Loc (
id <- 'id0' + thisModule.counter)
do {
thisModule.counter<- thisModule.counter+1;
locR;
}
Cheers,
Dennis
|
|
|
Re: Lazy rule: problem with a counter [message #1763857 is a reply to message #1763800] |
Mon, 22 May 2017 09:38 |
im hello world Messages: 44 Registered: February 2017 |
Member |
|
|
Hi Dennis,
Thank you very much,
but it doesn't work, i always get the same problem.
well, i tried to do the counter in a helper just like this
helper def: Id : Integer = 0;
helper def: getId() : String =
thisModule.refSetValue('Id', thisModule.Id + 1).Id.toString();
so my lazy rule becomes:
lazy rule LocReady {
from
b: BP!Bo
to
locR: upp!Loc (
id <- 'id0' + thisModule.getId()
...)
and when i call it in my matched rule to reference to the id of locR i always get the same problem: the reference appear but,
it doesn't references to the locR id, it continues to be incremented , so as a result i get the wrong id reference.
I don't really find the cause that the id created in a lazyRule , when called in a matched rule, don't stop to be incremented
[Updated on: Mon, 22 May 2017 09:40] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03719 seconds