views:

136

answers:

4

Hello. I have problem. I ll try to explain it.

I have a unit which has a class and may will have new functions.

D3BF4E849ACC45249B990F802EFB1F15\UnitFile1.pas 8DC8977E7A7B469AACFE3CC77CA7075E\UnitFile1.pas

Both of them have same class: IClass_1 = class

Im using code numbers for different versions of this file.

Another unit file (UnitFile2.pas) uses that unit file (UnitFile1.pas).

Also, second unit file (UnitFile2.pas) has different versions.

F94C439C822E490DB228F2C16EF2C190\UnitFile2.pas 14CEEFAFF1D64DDD8CBDEDD334D4A3FF\UnitFile2.pas

Both of them have same class: IClass_2 = class(IClass_1)

Now problem starts;

"F94C439C822E490DB228F2C16EF2C190\UnitFile2.pas" needs "D3BF4E849ACC45249B990F802EFB1F15\UnitFile1.pas"

"14CEEFAFF1D64DDD8CBDEDD334D4A3FF\UnitFile2.pas" needs "8DC8977E7A7B469AACFE3CC77CA7075E\UnitFile1.pas"

But file names are same (I need a system like this. So they are same). And in unit file, delphi doesn't let me to write like that;

In file F94C439C822E490DB228F2C16EF2C190\UnitFile2.pas; uses UnitFile1 in 'D3BF4E849ACC45249B990F802EFB1F15\UnitFile1.pas';

I hope i could tell my problem. How can i tell the compiler which unit file i want to use with its path? (Im using Delphi-7)

+1  A: 

You have to configure your Project Options to put the "D3BF4E849ACC45249B990F802EFB1F15" and "F94C439C822E490DB228F2C16EF2C190" in the search paths. You can't specify the unit paths in code.

Remy Lebeau - TeamB
A: 

As far as I know, you cannot add two units with the same name to a project.

You can add the correct folder to the Project Options, or you can add the necessary units to the 'View - Project Manager' screen (right-click the project name and choose 'Add'. Pick the correct unit in the correct folder, and from than on you can use just the unit name in every form and other unit in your project.

Why you would want to use such cryptic folder names is really beyond me. I can't think of any, any reason why you would want to do this.

Edelcom
i can explain it like that.Example i have a class and will develop it in time and it will have different versions. But class' name will be still same and also unit file's name. But i ll put this unit files into different folders. Folder's names will be like as i wrote in my question. Example:F94C439C822E490DB228F2C16EF2C190\classfile.pasD3BF4E849ACC45249B990F802EFB1F15\classfile.pas...So which version to use if i want, i ll use it's folder name but with same unit file name. I can do this in C like that;#include "D3BF4E849ACC45249B990F802EFB1F15\classunit.pas"Delphi doesnt let me.
Tolga
Yes, you can. And at project level (not in every source file). Just look at my answer: choose 'View - Project Manager', right-click on the name of the project "Project1.exe" (or whatever you call your program), and choose 'Add'. Pick the correct unit in the correct folder, and just use the unit name in your source files. If you later on want another version, delete the first version first (from the Project Manager, and 'Add' the new version.
Edelcom
I was just wondering why you should use such **cryptic folder names** (not that you have different folders for subsequent versions). Part of being a programmer, in my opinion, is protecting yourself from possible future mistakes. Using such crypting (non meaningfull) folders just makes it harder for your self to use them (in stead of folders as 'Version1', 'Version2' or 'Version_0911' (for nov 2009) and 'Version_1001' (for jan 2010). But every programmer has a certain style, and if it works for you, it works for you.
Edelcom
+1  A: 

Give your unit names DIFFERENT names, you can then simply include both units in the project.

Then use a unit alias in your project options to create a "virtual unit name" which resolves to one or other of these actual units. In units which "use" one or other of these reference them by the unit alias - the "virtual name".

e.g. in the dpr:

  uses
    ...
    UnitFile1a in '....\UnitFile1a.pas',
    UnitFile1b in '....\UnitFile1a.pas',
    ...

In your units:

   uses
     UnitFile1;

In your project options a unit alias that is either:

   UnitFile1=UnitFile1a

OR

   UnitFile1=UnitFile1b

You can then build your project with whichever "UnitFile1?" unit is appropriate by simply changing the unit alias.

Deltics
A: 

I am not sure whether this solves your problem, but there is the concept of namespaces, which allows you to put dots into unit names like this:

Rather than having the same filename in different directories ...

D3BF4E849ACC45249B990F802EFB1F15\UnitFile1.pas 8DC8977E7A7B469AACFE3CC77CA7075E\UnitFile1.pas

F94C439C822E490DB228F2C16EF2C190\UnitFile2.pas 14CEEFAFF1D64DDD8CBDEDD334D4A3FF\UnitFile2.pas

you could use a filename prefix:

D3BF4E849ACC45249B990F802EFB1F15.UnitFile1.pas 8DC8977E7A7B469AACFE3CC77CA7075E.UnitFile1.pas

F94C439C822E490DB228F2C16EF2C190.UnitFile2.pas 14CEEFAFF1D64DDD8CBDEDD334D4A3FF.UnitFile2.pas

You can then use the full filenames in the uses clause, e.g.:

uses
  D3BF4E849ACC45249B990F802EFB1F15.UnitFile1;

Yes, this works with Delphi 7.

dummzeuch