if problem

0 views
Skip to first unread message

gaurav v bagga

unread,
Jan 30, 2007, 2:27:28 AM1/30/07
to Tefkat
hi,

how to use MAKE inside if?

reg
gaurav...

michael lawley

unread,
Jan 30, 2007, 3:37:27 AM1/30/07
to Tef...@googlegroups.com
The IF first needs to be inside a SET

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

gaurav v bagga

unread,
Jan 30, 2007, 3:46:28 AM1/30/07
to Tefkat
hi.

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

gaurav v bagga

unread,
Jan 30, 2007, 3:53:58 AM1/30/07
to Tefkat
well i want to use if like:----->


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

David

unread,
Jan 30, 2007, 8:42:18 AM1/30/07
to Tefkat
Hi 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

michael lawley

unread,
Jan 30, 2007, 9:39:49 AM1/30/07
to Tef...@googlegroups.com
Just one extra thing to add to David's response - you can check the
type of an object more easily (and ore efficiently) as follows

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:
>

Reply all
Reply to author
Forward
0 new messages