[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmt] Re: [MOFScript]How to write this loop in MOFScript

Hello

It would be easier for me to answer your question if you could provide me the metamodel. But is what you are looking for the possibility to iterate all of the outgoings? The o.outgoing->forEach(p:Outport) should iterate them, then you can du the same at the level below. To me it seems as if this is a case that lends it self toward recursion?

Anyways, if you provide me more details I may be able to be of more help

Regards

Tor Neple

yeliu wrote:
Hello,
Anyone knows how to write this code into loop:
------------------------------------------
self.objects->forEach(o:Object)
'Connect '
o.name'.outport['1']->'o.outgoing.first().name ' -> '
o.outgoing.first().outputs.first().name '->
'o.outgoing.first().outputs.first().outgoing.first().name ' ->
'o.outgoing.first().outputs.first().outgoings.first().outputs.first().name'.inport['1']'
nl
'Connect '
o.name'.outport['2']->'o.outgoing.last().name ' -> '
o.outgoing.last().outputs.first().name ' ->
'o.outgoing.last().outputs.last().outgoing.first().name ' -> '
o.outgoing.last().outputs.last().outgoing.first().outputs.first().name
'.inport['2']' nl
-----------------------
In the above code, to simplify,o has 2 outports and 2 outgoings,and I
use outgoing.first() and outgoing.last() to print the two elements in
outgoing list.But acturally,o may have more than 1 outports.o's outgoing
is a list which contains more than 1 elements.

Can anyone help me?
Thank you for your help in advance!


Ye