Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Calculate in XTend Template without output
Calculate in XTend Template without output [message #1059812] Tue, 21 May 2013 13:24 Go to next message
Liroth Lustim is currently offline Liroth Lustim
Messages: 12
Registered: May 2013
Junior Member
Hello,

I am trying to do some calculations in loops and everytime I calculate something it is written in the file but I don't want this, so how can I suppress it?

Example:
«var n = -1»
«FOR i: p.list_item»
   «n=n+1» «««I dont't want this calculation in my outputfile
   ««« more stuff...
«ENDFOR»


Thanks for any help
Liroth
Re: Calculate in XTend Template without output [message #1059814 is a reply to message #1059812] Tue, 21 May 2013 13:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
e.g. «n=n+1;""» or you move the inc to a void method
Re: Calculate in XTend Template without output [message #1059815 is a reply to message #1059814] Tue, 21 May 2013 13:39 Go to previous messageGo to next message
Liroth Lustim is currently offline Liroth Lustim
Messages: 12
Registered: May 2013
Junior Member
if I try: «n=n+1;""» I get the error: " no viable alternative at input ';' "
how do I increase n in my loop without returning something from the called void function? is there something like a pointer from C which I can use in the function calling?
Re: Calculate in XTend Template without output [message #1059816 is a reply to message #1059815] Tue, 21 May 2013 13:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
hmmm should be «{n=n+1;""}»
Re: Calculate in XTend Template without output [message #1059817 is a reply to message #1059816] Tue, 21 May 2013 13:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
btw depending on what you want to do it may not be neccessary todo the looping within the template at all but in normal xtend code.
Re: Calculate in XTend Template without output [message #1059818 is a reply to message #1059816] Tue, 21 May 2013 13:50 Go to previous messageGo to next message
Liroth Lustim is currently offline Liroth Lustim
Messages: 12
Registered: May 2013
Junior Member
Thanks, this works!
Re: Calculate in XTend Template without output [message #1059959 is a reply to message #1059818] Wed, 22 May 2013 07:19 Go to previous messageGo to next message
Liroth Lustim is currently offline Liroth Lustim
Messages: 12
Registered: May 2013
Junior Member
Hi,

can you pleas explain what this is and what it does or why it does this?

Thanks a lot!
Liroth
Re: Calculate in XTend Template without output [message #1059965 is a reply to message #1059959] Wed, 22 May 2013 07:39 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
Is is a block with 2 expressions. The last defines the return value
of the block

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Previous Topic:reload all elements from the XMFResource
Next Topic:Integration of GMF and Xtext -> Problem with ResourceDescription
Goto Forum:
  


Current Time: Tue May 28 17:17:15 EDT 2013

Powered by FUDForum. Page generated in 0.01757 seconds