Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [XPand2] setting local variables
[XPand2] setting local variables [message #805869] Fri, 24 February 2012 08:36 Go to next message
Florian Reischl is currently offline Florian ReischlFriend
Messages: 5
Registered: February 2012
Junior Member

I want to set a local variable to another value, for example:

«LET false AS itemFound»
«FOREACH ... AS ...»
«IF ...»
 «REM»do sth and set the variable itemFound to true«ENDREM»
 itemFound = true

How can I do this?

[Updated on: Fri, 24 February 2012 09:06]

Report message to a moderator

Re: [XPand2] setting local variables [message #805893 is a reply to message #805869] Fri, 24 February 2012 09:09 Go to previous message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

The LET statement binds the result of an expression to a variable. There is no concept in Xpand to define variables, and usually it is not needed.

Anyway, to come around this you could use the elementprops extensions from stdlib.

extension org::eclipse::xtend::util::stdlib::elementprops;
«this.setProperty("itemFound", false)»
«IF ...»
  «this.setProperty("itemFound", true)»

You should always ask yourself: Do I really need this? I do not know your usecase, but it is likely that you could come around your issue with a smarter use of extension functions for your template. I have programmed so many templates, and don't have a real need for local variables in 99%. Also I avoid to use LET in favor of extension functions whenever applicable.


Need professional support for Xtext, EMF, Eclipse IDE?
Go to:
Twitter : @kthoms
Blog :
Previous Topic:[acceleo] best way to pass extra data from Java to template ?
Next Topic:[Acceleo] Errors running builder 'Acceleo Builder'
Goto Forum:

Current Time: Wed Sep 28 07:42:14 GMT 2022

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

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

Back to the top