Book a Demo

Author Topic: Relative path in code generation  (Read 3756 times)

janigorse

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Relative path in code generation
« on: August 18, 2005, 05:42:48 am »
Hi!


I have 2 questions:

1. Is it possible to define a relative path, to wich code will be generated? By default you must specify a location like: "C:\Projects\MyProject\". So, is it posible to define "\Projects\MyProject\" path?

2. Is it possible to define a common "using" directives for each class? I want a "using System, using System.Data"
directives to be in a generated class, instead of that I must typed it myself.

Thanks for the answers,
Jani

thomaskilian

  • Guest
Re: Relative path in code generation
« Reply #1 on: August 18, 2005, 06:58:17 am »
1) specify ./restofpath, where the leading period is the directory where the repository is located. ../restopfpath goes up accordingly.
« Last Edit: August 18, 2005, 07:04:26 am by thomaskilian »

janigorse

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Relative path in code generation
« Reply #2 on: August 18, 2005, 11:57:04 am »
Yes I know what you mean, but where can I specify ./path? Wich menu or window?

AshK

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: Relative path in code generation
« Reply #3 on: August 18, 2005, 04:38:37 pm »
Hi Jani,

You may specify the filename in the elements property sheet (Alt + 1).  

When specifying relative paths I recommend using the Local Paths feature:

http://sparxsystems.com.au/EAUserGuide/localpaths.htm

-Ash
The Sparx Team
[email protected]

AshK

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: Relative path in code generation
« Reply #4 on: August 18, 2005, 04:50:56 pm »
Oh, and for your 2nd question:

There's a couple of options here, either enter the using statements in the Import Headers field on the Generate Code dialog, or modify the Import code template.

The Import Headers are applied on a per class basis, where as the code templates method will be applied to all classes.

To achieve what you wanted using code templates:
- Open the template editor (Configuration->Code Generation Templates)
-Add the following lines to the bottom of the Import "Import Section" template for C#

using System;
using System.Data;

HTH :),

Ash
« Last Edit: August 21, 2005, 05:34:06 pm by AshK »
The Sparx Team
[email protected]

janigorse

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Relative path in code generation
« Reply #5 on: August 19, 2005, 01:26:57 am »
Quote
Hi Jani,

You may specify the filename in the elements property sheet (Alt + 1).  

When specifying relative paths I recommend using the Local Paths feature:

http://sparxsystems.com.au/EAUserGuide/localpaths.htm

-Ash



Thanks Ash! As you can see I'm a newbie in EA :) I did all that steps that you specify above, but I keep getting message "Process complete! 0 records affected." So there is no change in the filename property of the classes in my model. What I'm doing wrong?

AshK

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: Relative path in code generation
« Reply #6 on: August 21, 2005, 05:32:21 pm »
Hi Jani,

Just to clarify, the Apply Path button will perform a find and replace on all codegen paths (filename field) in the model, substituing  instances of Path with %ID%.  Also, this will only affect elements that have a Language that matches the Local Path's Type field.

Expand path is the inverse of Apply Path - substituting %ID% with Path.

I noticed I made a mistake in the answer to your 2nd question regarding import headers:  please modify the "Import Section" template, not "Import".

I should also note, this import section won't be generated when synching to an existing file, but only when the file is being created or overwritten.

HTH,

Please reply if you are still having trouble.

Ash
« Last Edit: August 21, 2005, 05:35:02 pm by AshK »
The Sparx Team
[email protected]