Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » GMT (Generative Modeling Technologies) » [MOFScript]print two list at the same time
[MOFScript]print two list at the same time [message #385194] Wed, 27 August 2008 07:41 Go to next message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hello,
Now I have two list <String>,I want to show them at the same time,E.g
list1[1]->List2[1]
List1[2]->List2[2]
Since in MOFScript,only one list could be printed once by using
List->forEach()
How should I write this code in MOFScript?



Many thanks!


Ye
Re: [MOFScript]print two list at the same time [message #385199 is a reply to message #385194] Wed, 27 August 2008 11:14 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,

The example bellow should give you a hint.

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

Cheers,
G
Re: [MOFScript]print two list at the same time [message #385201 is a reply to message #385199] Wed, 27 August 2008 12:35 Go to previous messageGo to next message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hello,
Thank you very much,but it seems the get() is unrecognized in MOFScipt
syntax.Do I need to add some import to use this function?Or Is there any
built in function for getting elements in a list in MOFScript ?


Thank you !


Ye
Re: [MOFScript]print two list at the same time [message #385203 is a reply to message #385201] Wed, 27 August 2008 14:41 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
I just ran the example I provided in my MOFScript instalation.
However there might be a bug with the content assist not showing the get
keyword.

If you copy the code into your editor or try to write get() I am sure it
should work.

/G
Re: [MOFScript]print two list at the same time [message #385206 is a reply to message #385203] Thu, 28 August 2008 06:32 Go to previous messageGo to next message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hi,
Besides those functions listed in the MOFScript developer guide,there
are two more functions:contains(obj) and select() listed in the content
assistant of List.But the get() are highlightend in my editor.It's just
when I execute the code,it says'#Runtime Error in FunctionCallEvaluator
318# Unknown function get for type java.util.ArrayList(line: 53)'
If this is a bug,how should I do to avoid it or is there another way to
get the elements in the list excepte using get()?
In addition,there is such commects in the console view 'name: list1.get,
isSuperCall: false'.Does it means this is a superCall which shouldn't be
applied to subClass? How should I do to prevent it?


Thank you very much!
Re: [MOFScript]print two list at the same time [message #385265 is a reply to message #385203] Thu, 28 August 2008 06:44 Go to previous messageGo to next message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hi,
Or the thing is like this:there is no way to print elements in a list
freely.It only can be printed all together?As long as you want print
element in a list ,you have to print them all ,continually,no way to print
a specific one?



Regards

Ye
Re: [MOFScript]print two list at the same time [message #385266 is a reply to message #385265] Thu, 28 August 2008 07:26 Go to previous message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
Ye,

looking at the code example I gave you should answer your questions.

Cheers,
G
Re: [MOFScript]print two list at the same time [message #620439 is a reply to message #385194] Wed, 27 August 2008 11:14 Go to previous message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
Hello Ye,

The example bellow should give you a hint.

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

Cheers,
G
Re: [MOFScript]print two list at the same time [message #620443 is a reply to message #385199] Wed, 27 August 2008 12:35 Go to previous message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hello,
Thank you very much,but it seems the get() is unrecognized in MOFScipt
syntax.Do I need to add some import to use this function?Or Is there any
built in function for getting elements in a list in MOFScript ?


Thank you !


Ye
Re: [MOFScript]print two list at the same time [message #620447 is a reply to message #385201] Wed, 27 August 2008 14:41 Go to previous message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
I just ran the example I provided in my MOFScript instalation.
However there might be a bug with the content assist not showing the get
keyword.

If you copy the code into your editor or try to write get() I am sure it
should work.

/G
Re: [MOFScript]print two list at the same time [message #620455 is a reply to message #385203] Thu, 28 August 2008 06:32 Go to previous message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hi,
Besides those functions listed in the MOFScript developer guide,there
are two more functions:contains(obj) and select() listed in the content
assistant of List.But the get() are highlightend in my editor.It's just
when I execute the code,it says'#Runtime Error in FunctionCallEvaluator
318# Unknown function get for type java.util.ArrayList(line: 53)'
If this is a bug,how should I do to avoid it or is there another way to
get the elements in the list excepte using get()?
In addition,there is such commects in the console view 'name: list1.get,
isSuperCall: false'.Does it means this is a superCall which shouldn't be
applied to subClass? How should I do to prevent it?


Thank you very much!
Re: [MOFScript]print two list at the same time [message #620456 is a reply to message #385203] Thu, 28 August 2008 06:44 Go to previous message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hi,
Or the thing is like this:there is no way to print elements in a list
freely.It only can be printed all together?As long as you want print
element in a list ,you have to print them all ,continually,no way to print
a specific one?



Regards

Ye
Re: [MOFScript]print two list at the same time [message #620458 is a reply to message #385265] Thu, 28 August 2008 07:26 Go to previous message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
Ye,

looking at the code example I gave you should answer your questions.

Cheers,
G
Previous Topic:[Eugenie].emf file association gone weird
Next Topic:[MOFScript]How to write this loop in MOFScript
Goto Forum:
  


Current Time: Thu Mar 28 14:05:25 GMT 2024

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

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

Back to the top