Book a Demo

Author Topic: How to transfer variables to CG-templates?  (Read 2347 times)

Physicus

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
How to transfer variables to CG-templates?
« on: February 01, 2006, 09:08:10 am »
Hi,

is it possible to transfer variables to code generation templates in any way?

My situation:
I have evaluated a variable within a cg-template. Now from this cg-template an other one is called (not directly but through the list macro). I want to have the evaluated value within the inner template. How to do?

I tried to simply store the value in a class tag an then read it out within the inner template, but this doesnt work (it's not allowed to write into the predefined variables).

What can I do?

thomaskilian

  • Guest
Re: How to transfer variables to CG-templates?
« Reply #1 on: February 01, 2006, 12:38:20 pm »
You can likely use EXEC_ADD_IN to perform what you need. (I might be wrong, though)

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: How to transfer variables to CG-templates?
« Reply #2 on: February 01, 2006, 01:00:58 pm »
Are you wanting to do that to avoid recalculating something and including the same code multiple times?

If not, all macros available in one template should also be available in anything you'll call it from.

Physicus

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: How to transfer variables to CG-templates?
« Reply #3 on: February 01, 2006, 09:13:19 pm »
My Problem deals with the list function. I have to list over all attributes and within the attribute declaration template I have to know the length (in characters) of the longest attribute in the class (due to formatting reasons). Therefore I developed an AddIn which returns the longest attribute string among all attributes. I call this AddIn from the template which later on calls the list function to do the formatting output. Now I need to "see"  the so calculated length of the longest attribute within the attribute declaration template (called from the list function).
Of course I could call my AddIn from within the attribute declaration template each time this template is invoked from the list function. But this would be an enormous waste of cpu-time!

Edit: The last is not possible, because it would end up with an endless loop.
« Last Edit: February 01, 2006, 09:24:29 pm by Physicus »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: How to transfer variables to CG-templates?
« Reply #4 on: February 02, 2006, 01:19:28 pm »
You could try changing the attribute template generate everything to a string.  You can then get the length of that string in the template (LENGTH() macro) although if the calculated length needs to include the length generated you'll need to use an addin call with the full declaration passed in.