Looping Structure [message #1233995] |
Tue, 21 January 2014 01:29 |
Huseyin Ergin Messages: 4 Registered: January 2014 |
Junior Member |
|
|
Hi everyone
I checked some manuals and web pages of viatra2, but couldnt find. Do you know we can do a conditional execution or a loop like structure in viatra2?
Like: If ruleA.success; then apply ruleB, else apply ruleC.
OR: (Apply ruleA, then ruleB) -> do this sequence until one fails (or first one fail)?
By the way, I had a 2006 dated manual pdf, do you know a newer version?
[Updated on: Tue, 21 January 2014 01:30] Report message to a moderator
|
|
|
Re: Looping Structure [message #1234269 is a reply to message #1233995] |
Tue, 21 January 2014 15:26 |
Abel Hegedus Messages: 197 Registered: September 2015 |
Senior Member |
|
|
There are two ASM functions related to repeated execution, forall and iterate. Combining them with try, if and choose will give you a quite powerful language.
Additionally, while GT rules are supported by VIATRA2, you may be better off using ASM rules instead.
For the example you mentioned:
rule ifAthenBelseC() = seq{
try call AthenB(); // if AthenC fails, then C is executed
else call C(); // if C fails, ifAthenBelseC fails as well
}
rule main() = seq{
iterate call ifAthenBelseC(); // ifAthenBelseC is executed repeatedly, until it fails
}
Finally, for a more recent example set, see our Hello World solution for TTC 2011 in the case studies page.
|
|
|
Powered by
FUDForum. Page generated in 0.03115 seconds