Book a Demo

Author Topic: Macro expansion in GenPath  (Read 3194 times)

AndreasKo

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Macro expansion in GenPath
« on: June 22, 2011, 01:43:53 am »
Hi all,

I have a VB script that sets the Genfile attribute of an element to specify the file name for code generation:
Code: [Select]
currentElement.Genfile = BASE_PATH & "\" & currentElement.Name & ".java"
How can I use a macro in BASE_PATH so that each developer can set it to their own local directory? From the EA users guide (search for macro expansion in EA help):
Quote
GenFile : String : Read/Write. The file associated with this element for code generation and synchronization purposes. Can include macro expansion tags for local conversion to full path.

Can I use the "Default Source Directory" from the Options dialog (Tools/Options/Source Code Engineering/Java) in BASE_PATH?

Tried a field substitution macro but it didn't work:
Code: [Select]
const BASE_PATH = "%genOptJavaDefaultSourceDirectory%\MyProject\src\main\java\com\mycompany"Seems like these can only be used in code generation templates, not in VB scripts operating on the model.

Thanks,
Andreas
« Last Edit: June 22, 2011, 02:06:06 am by AndreasKo »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Macro expansion in GenPath
« Reply #1 on: June 22, 2011, 08:19:54 am »
See Local Paths in the help.

AndreasKo

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Macro expansion in GenPath
« Reply #2 on: June 22, 2011, 05:23:51 pm »
Simon,

it works!

I entered a new local path "CodeGenPrefix" with type Java and my local path s:\svn_src. And clicked Apply path. Now I replaced my earlier definition in my VB script to:

Code: [Select]
const BASE_PATH = "%CodeGenPrefix%\MyProject\src\main\java\com\mycompany"
When generating code with code engineering after running my script, I now get this prefix replaced with my local path.

Thanks,
Andreas