how to use MAKE inside if?
reg
gaurav...
RULE ...
SET IF y = "a" THEN
MAKE Foo f
ENDIF
The syntax is very ugly, sorry about that -- it was something that we
added very late and we were constrained by existing decisions (and a
lack of imagination :-)
michael
good thing its there
otherwise i would have gone crazy how to accomplish what i am trying
to do now.
once done will post to ask well i am going the right way.
truly never done such model transformation before everything is greek
to me
but sure enjoying it.
gaurav
RULE processGraphicalElements
FORALL Process P
WHERE GE = P.GraphicalElements
AND GE.eClass().getName()="Task"
AND IF GE.eClass().getName() = "Task" THEN
//////////////////////////////////////////////////
SET IF GE.eClass().getName() = "Task" THEN
MAKE Invoke f
ENDIF
/////////////////////////////////////////////////
ENDIF
;
can you just help arrange this in better way
actually i want to iterate over graphical elements and do operation on
each according to its type.
gaurav
Perhaps you want something like this:
RULE ProcessGraphicalElements
FORALL Process p
WHERE ge = p.graphicalElements
AND ge.eClass().name = n
SET IF n = "Task"
THEN MAKE ...
ELSEIF n = "Foo"
THEN MAKE ...
...
ENDIF
;
There is an important distinction between query-like parts of a rule
(FORALL ... WHERE ...) and assertion-like parts of a rule (MAKE ...
SET ... LINKING ...), and a rule always has the structure:
RULE R
<query part>
<assertion part>
;
where the query part, also called the source term, is written using
FORALL and WHERE, and the assertion part (called the target term), is
written using MAKE, SET and LINKING.
An IF can only occur in the WHERE clause or in the SET clause. An IF
in the WHERE clause, called a source-side IF, is written as:
IF term THEN term
(ELSEIF term THEN term)*
[ELSE term]
ENDIF
and an IF in the SET clause, called a target-side IF, is written as:
IF term THEN [MAKE ...] [SET ...] (LINKING ...)*
ELSEIF term THEN [MAKE ...] [SET ...] (LINKING ...)*
ELSE [MAKE ...] [SET ...] (LINKING ...)*
ENDIF
Just like other things in the SET clause, multiple IFs can be
separated by commas.
SET IF ... THEN ... ELSE ... ENDIF,
IF ... THEN ... ELSE ... ENDIF,
...
Hope this helps,
-David
RULE processGraphicalElements
FORALL Process P
WHERE GE = P.GraphicalElements
AND Task GE
MAKE Invoke f
;
or
RULE processGraphicalElements
FORALL Process P, Task GE
WHERE GE = P.GraphicalElements
MAKE Invoke f
;
or, if you want multiple tests in the one rule
RULE processGraphicalElements
FORALL Process P
WHERE GE = P.GraphicalElements
SET
IF Task GE
THEN MAKE Invoke f
ELSEIF Foo GE
THEN MAKE Bar f
// ...
ENDIF
;
On 30/01/07, gaurav v bagga <gaurav....@gmail.com> wrote:
>