Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » GMT (Generative Modeling Technologies) » [MOFScript]i+=1 acturally add by two
[MOFScript]i+=1 acturally add by two [message #385282] Fri, 29 August 2008 10:54 Go to next message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hello,
I found that i+=1 add by 2 instead of 1,How to write it add by 1?


Thanks!


Ye
Re: [MOFScript]i+=1 acturally add by two [message #385283 is a reply to message #385282] Fri, 29 August 2008 12:01 Go to previous messageGo to next message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
Hello Ye,

This sounded strange.........

The following transformation gives tho output output below on my computer:

uml.Model::main () {
var l1:List
var l2:List
var counter:Integer = 5
counter->forEach(n){
l1.add(n+" : l1")
l2.add(n+" : l2")
}
var counter2:Integer = 0
while(counter2 < l1.size() || counter2 < l1.size()){
if ( l1.get(counter2)!=null ){
stdout.print("List 1: "+l1.get(counter2))
}
if ( l2.get(counter2)!=null ){
stdout.print(" - List 2: "+l2.get(counter2))
}
stdout.println("")
counter2 +=1
stdout.println("Hola: "+counter2)
}
}
}


## Executing MOFScript Specification
## Starting transformation: "ExampleTransformation"
List 1: 1 : l1 - List 2: 1 : l2
Hola: 1
List 1: 2 : l1 - List 2: 2 : l2
Hola: 2
List 1: 3 : l1 - List 2: 3 : l2
Hola: 3
List 1: 4 : l1 - List 2: 4 : l2
Hola: 4
List 1: 5 : l1 - List 2: 5 : l2
Hola: 5
## Finished transformation: "ExampleTransformation"


So how you manage to make it add 2, I do not know.

/G
Re: [MOFScript]i+=1 acturally add by two [message #385310 is a reply to message #385283] Mon, 01 September 2008 06:18 Go to previous messageGo to next message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hello,
My code looks like this:

var j:Integer =1
o.outgoing->forEach(c:Channel){
'Connect ' o.name'.outport['j']->'c.name ' ->
'c.outputs.first().name '-> 'c.outputs.first().outgoing.first().name ' ->
'o.outgoing.first().outputs.first().outgoing.first().outputs .first().name'.inport['j']'

nl j+=1
}
----------------------
and the generated code looks like this:
Connect s4.outport[1]->ch9 -> n7-> ch11 -> g6.inport[1]
Connect s4.outport[3]->ch10 -> n8-> ch12 -> g6.inport[3]

(there are two elements in o.outgoing.)

Strange


regards

Ye
Re: [MOFScript]i+=1 acturally add by two [message #385314 is a reply to message #385310] Mon, 01 September 2008 08:34 Go to previous messageGo to next message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
Hello,

For simplicity, could you provide me with your metamodel, model and
transformation.

Cheers,
G
Re: [MOFScript]i+=1 acturally add by two [message #385315 is a reply to message #385314] Mon, 01 September 2008 10:48 Go to previous message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hello,
Is there a way to add attachment in post?
Re: [MOFScript]i+=1 acturally add by two [message #621679 is a reply to message #385282] Fri, 29 August 2008 12:01 Go to previous message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
Hello Ye,

This sounded strange.........

The following transformation gives tho output output below on my computer:

uml.Model::main () {
var l1:List
var l2:List
var counter:Integer = 5
counter->forEach(n){
l1.add(n+" : l1")
l2.add(n+" : l2")
}
var counter2:Integer = 0
while(counter2 < l1.size() || counter2 < l1.size()){
if ( l1.get(counter2)!=null ){
stdout.print("List 1: "+l1.get(counter2))
}
if ( l2.get(counter2)!=null ){
stdout.print(" - List 2: "+l2.get(counter2))
}
stdout.println("")
counter2 +=1
stdout.println("Hola: "+counter2)
}
}
}


## Executing MOFScript Specification
## Starting transformation: "ExampleTransformation"
List 1: 1 : l1 - List 2: 1 : l2
Hola: 1
List 1: 2 : l1 - List 2: 2 : l2
Hola: 2
List 1: 3 : l1 - List 2: 3 : l2
Hola: 3
List 1: 4 : l1 - List 2: 4 : l2
Hola: 4
List 1: 5 : l1 - List 2: 5 : l2
Hola: 5
## Finished transformation: "ExampleTransformation"


So how you manage to make it add 2, I do not know.

/G
Re: [MOFScript]i+=1 acturally add by two [message #621696 is a reply to message #385283] Mon, 01 September 2008 06:18 Go to previous message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hello,
My code looks like this:

var j:Integer =1
o.outgoing->forEach(c:Channel){
'Connect ' o.name'.outport['j']->'c.name ' ->
'c.outputs.first().name '-> 'c.outputs.first().outgoing.first().name ' ->
'o.outgoing.first().outputs.first().outgoing.first().outputs .first().name'.inport['j']'

nl j+=1
}
----------------------
and the generated code looks like this:
Connect s4.outport[1]->ch9 -> n7-> ch11 -> g6.inport[1]
Connect s4.outport[3]->ch10 -> n8-> ch12 -> g6.inport[3]

(there are two elements in o.outgoing.)

Strange


regards

Ye
Re: [MOFScript]i+=1 acturally add by two [message #621700 is a reply to message #385310] Mon, 01 September 2008 08:34 Go to previous message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
Hello,

For simplicity, could you provide me with your metamodel, model and
transformation.

Cheers,
G
Re: [MOFScript]i+=1 acturally add by two [message #621743 is a reply to message #385314] Mon, 01 September 2008 10:48 Go to previous message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hello,
Is there a way to add attachment in post?
Previous Topic:[Epsilon]EWL Wizards problem
Next Topic:[Epsilon] pre/post condition in EWL
Goto Forum:
  


Current Time: Thu Mar 28 18:15:36 GMT 2024

Powered by FUDForum. Page generated in 0.07616 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top