[XPand2] setting local variables [message #805869] |
Fri, 24 February 2012 08:36 |
Florian Reischl Messages: 5 Registered: February 2012 |
Junior Member |
|
|
Hello,
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
«ENDIF»
«ENDFOREACH»
«ENDLET»
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 |
|
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.
Regards,
~Karsten
Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
|
|
|
Powered by
FUDForum. Page generated in 0.04172 seconds