Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Does the Acceleo Language support constants?
[Acceleo] Does the Acceleo Language support constants? [message #701821] Mon, 25 July 2011 12:26 Go to next message
Eclipse UserFriend
Hello everybody

I need to use some string values in more than one module (.mtl file) in my project. I am looking for a way to define macros or constants in a single place and use them in multiple places (much like the #define directive of C's preprocessor). I checked let blocks, but I don't think the variables defined by them can be used in different modules. I think that defining a number of queries each returning the appropriate value would be a way to centralize the definition of a fixed value that can be used in multiple modules, but doesn't seem too elegant to me.

Does any expert in Acceleo know about a way to define constants?

Thanks. Kindest regards.
(no subject) [message #701835 is a reply to message #701821] Mon, 25 July 2011 12:55 Go to previous messageGo to next message
Eclipse UserFriend
Hi

You can define an additional Constants.ecore meta-model with all your
favourite valiures in.

Regards

Ed Willink

On 25/07/2011 17:26, Balderas wrote:
> Hello everybody
>
> I need to use some string values in more than one module (.mtl file)
> in my project. I am looking for a way to define macros or constants in
> a single place and use them in multiple places (much like the #define
> directive of C's preprocessor). I checked let blocks, but I don't
> think the variables defined by them can be used in different modules.
> I think that defining a number of queries each returning the
> appropriate value would be a way to centralize the definition of a
> fixed value that can be used in multiple modules, but doesn't seem too
> elegant to me.
>
> Does any expert in Acceleo know about a way to define constants?
>
> Thanks. Kindest regards.
Re: (no subject) [message #702328 is a reply to message #701835] Tue, 26 July 2011 04:17 Go to previous message
Eclipse UserFriend
Hi,

Defining a set of queries returning the accurate String in their own module sure is one way to do it, but it does not seem like the easiest. If what you need are String constants, then the best way would be to define them in a properties file, and use these properties directly from your Acceleo module.

Stéphane had written a good post about how to use properties files with Acceleo 3.1 on his blog.

I'll only add that to access properties from an Acceleo module after you've followed his steps, you need to use one of the "getProperty" services the Acceleo syntax provides. See their definitions on the Acceleo operations reference.

Laurent Goubet
Obeo
Previous Topic:[ACCELEO] How to make Acceleo to use my model?
Next Topic:[MWE] Use metamodel from other plugin
Goto Forum:
  


Current Time: Wed Jul 23 14:31:53 EDT 2025

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

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

Back to the top