Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] setting the value of a global variable from xtend?
[Xpand] setting the value of a global variable from xtend? [message #646706] Thu, 30 December 2010 09:54 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

in my Xpand template I'd like to set the value of a variable to be
available during the generation of a model element, and I don't want to
pass that value to all the definitions...

I saw that Xpand provides GLOBALVAR

I'd like to set that var when I start to generate a model element, but I
can't see how to do that...

any help please?
thanks in advance
Lorenzo

P.S. sorry, I'v just started using Xpand...

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: [Xpand] setting the value of a global variable from xtend? [message #646709 is a reply to message #646706] Thu, 30 December 2010 10:19 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 12/30/2010 10:54 AM, Lorenzo Bettini wrote:
> Hi
>
> in my Xpand template I'd like to set the value of a variable to be
> available during the generation of a model element, and I don't want to
> pass that value to all the definitions...
>
> I saw that Xpand provides GLOBALVAR
>
> I'd like to set that var when I start to generate a model element, but I
> can't see how to do that...
>
> any help please?
> thanks in advance
> Lorenzo
>
> P.S. sorry, I'v just started using Xpand...
>

OK, I think I found the solution by googling much more, and I try to
answer myself :)

extension org::eclipse::xtend::util::stdlib::globalvar;

String getCurrentModelPackage() :
let currentModelPackage = (String) getGlobalVar("currentModelPackage") :
if(currentModelPackage == null) then (
storeGlobalVar("currentModelPackage", "")
) -> currentModelPackage
;

String setCurrentModelPackage(String s) :
storeGlobalVar("currentModelPackage", s)
;

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Previous Topic:[Acceleo 3] derived metamodel - type not recognized - eProxyURI
Next Topic:[Acceleo 3] getting All classes from Papyrus Model
Goto Forum:
  


Current Time: Thu Mar 28 12:58:12 GMT 2024

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

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

Back to the top