Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMT (Generative Modeling Technologies) » [MOFScript]couldn't print list element
[MOFScript]couldn't print list element [message #384895] Fri, 22 August 2008 13:49 Go to next message
yeliu is currently offline yeliu
Messages: 145
Registered: July 2009
Senior Member
Hello,
I have a class Sca,with one attribute List<String> xxx,I want print all
the elements in this list,I write the following statment in MOFScript.
In the context of Sca,
self.xxx->forEach(s:string)
print(s+",")
when I execute the code (of course ,this is not an empty list),none of the
elements is printed.Does anyone knows what the problem is?


Thanks a lot!

Ye
Re: [MOFScript]couldn't print list element [message #384908 is a reply to message #384895] Tue, 26 August 2008 07:31 Go to previous messageGo to next message
Gøran K. Olsen is currently offline Gøran K. Olsen
Messages: 184
Registered: July 2009
Senior Member
Hello Ye,

I guess this is related to your previous posting.

Cheers,
G
Re: [MOFScript]couldn't print list element [message #385187 is a reply to message #384908] Tue, 26 August 2008 07:50 Go to previous messageGo to next message
yeliu is currently offline yeliu
Messages: 145
Registered: July 2009
Senior Member
Hello,
I don't think this is related to the question about self. doesn't work.
I suppose maybe the syntax is wrong somewhere,but couldn't find any
clue.Do you have any idea?


Many thanks!


Ye
Re: [MOFScript]couldn't print list element [message #385188 is a reply to message #385187] Tue, 26 August 2008 08:32 Go to previous messageGo to next message
Gøran K. Olsen is currently offline Gøran K. Olsen
Messages: 184
Registered: July 2009
Senior Member
Hello,

Well, I am not sure what your (s:string) is. Is "s" a reference to some meta
thing in your metamodel? In that case you have forgotten the
inModel.string.. Like if you e.g. want to filter a collection to only return
a uml class you would have to write self.ownedElement->forEach(c: uml.Class)
where uml is the name of your input model parameter.

/G
Re: [MOFScript]couldn't print list element [message #385189 is a reply to message #385188] Tue, 26 August 2008 12:05 Go to previous messageGo to next message
yeliu is currently offline yeliu
Messages: 145
Registered: July 2009
Senior Member
Hello,
Well, the problem is still not solved.As I described in my first post,s
means a variable of type String.I think this iteration for string is
right,what do you think?
-------------------------------
I have a class Sca,with one attribute List<String> xxx,I want print all
the elements in this list,I write the following statment in MOFScript:
In the context of Sca,
self.xxx->forEach(s:string)
print(s+",")
--------------------------------

Thanks

Ye
Re: [MOFScript]couldn't print list element [message #385190 is a reply to message #385189] Tue, 26 August 2008 13:12 Go to previous messageGo to next message
Gøran K. Olsen is currently offline Gøran K. Olsen
Messages: 184
Registered: July 2009
Senior Member
Hello,

Running:
myMdl.Test::main(){

self.stringList->forEach(s){

stdout.println("A " + s)

}

}

on a model A (test- stringList[eeeeeeee, ttttttttttt]) conforming to
metamodel X containing 1 EClass that has 1 EAttribute of type EString upper
bound -1.

Gives the following result:

## Loading source model - My.test...(Loading time 16 - Msec)

## Executing MOFScript Specification

## Starting transformation: "ExampleTransformation"

A eeeee

A tttttttttttt


I can still not understand what this (s:string) of yours is...

Cheers,
G
Re: [MOFScript]couldn't print list element [message #385191 is a reply to message #385190] Tue, 26 August 2008 14:06 Go to previous message
yeliu is currently offline yeliu
Messages: 145
Registered: July 2009
Senior Member
Hello,
finally,the problem is solved by adding '{}' around the statment of
iteration.
I'm happy!


Thank you very much!


Ye
Re: [MOFScript]couldn't print list element [message #620054 is a reply to message #384895] Tue, 26 August 2008 07:31 Go to previous message
Gøran K. Olsen is currently offline Gøran K. Olsen
Messages: 184
Registered: July 2009
Senior Member
Hello Ye,

I guess this is related to your previous posting.

Cheers,
G
Re: [MOFScript]couldn't print list element [message #620058 is a reply to message #384908] Tue, 26 August 2008 07:50 Go to previous message
yeliu is currently offline yeliu
Messages: 145
Registered: July 2009
Senior Member
Hello,
I don't think this is related to the question about self. doesn't work.
I suppose maybe the syntax is wrong somewhere,but couldn't find any
clue.Do you have any idea?


Many thanks!


Ye
Re: [MOFScript]couldn't print list element [message #620059 is a reply to message #385187] Tue, 26 August 2008 08:32 Go to previous message
Gøran K. Olsen is currently offline Gøran K. Olsen
Messages: 184
Registered: July 2009
Senior Member
Hello,

Well, I am not sure what your (s:string) is. Is "s" a reference to some meta
thing in your metamodel? In that case you have forgotten the
inModel.string.. Like if you e.g. want to filter a collection to only return
a uml class you would have to write self.ownedElement->forEach(c: uml.Class)
where uml is the name of your input model parameter.

/G
Re: [MOFScript]couldn't print list element [message #620060 is a reply to message #385188] Tue, 26 August 2008 12:05 Go to previous message
yeliu is currently offline yeliu
Messages: 145
Registered: July 2009
Senior Member
Hello,
Well, the problem is still not solved.As I described in my first post,s
means a variable of type String.I think this iteration for string is
right,what do you think?
-------------------------------
I have a class Sca,with one attribute List<String> xxx,I want print all
the elements in this list,I write the following statment in MOFScript:
In the context of Sca,
self.xxx->forEach(s:string)
print(s+",")
--------------------------------

Thanks

Ye
Re: [MOFScript]couldn't print list element [message #620061 is a reply to message #385189] Tue, 26 August 2008 13:12 Go to previous message
Gøran K. Olsen is currently offline Gøran K. Olsen
Messages: 184
Registered: July 2009
Senior Member
Hello,

Running:
myMdl.Test::main(){

self.stringList->forEach(s){

stdout.println("A " + s)

}

}

on a model A (test- stringList[eeeeeeee, ttttttttttt]) conforming to
metamodel X containing 1 EClass that has 1 EAttribute of type EString upper
bound -1.

Gives the following result:

## Loading source model - My.test...(Loading time 16 - Msec)

## Executing MOFScript Specification

## Starting transformation: "ExampleTransformation"

A eeeee

A tttttttttttt


I can still not understand what this (s:string) of yours is...

Cheers,
G
Re: [MOFScript]couldn't print list element [message #620062 is a reply to message #385190] Tue, 26 August 2008 14:06 Go to previous message
yeliu is currently offline yeliu
Messages: 145
Registered: July 2009
Senior Member
Hello,
finally,the problem is solved by adding '{}' around the statment of
iteration.
I'm happy!


Thank you very much!


Ye
Previous Topic:[MOFScript]self. doesn't work
Next Topic:[MOFScript] Error in MOFScript generating code by Java
Goto Forum:
  


Current Time: Tue Sep 16 17:47:26 GMT 2014

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

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