2
votes

I have a delphi Application that has 3 units in it currently.

I have 2 forms Start_Interface_u,Login_u and a additional unit (with no form) called TMobileSystem_u.

In TMobileSystem_u I have a few classes.

TWebSystem = Class
  Protected
    FRequest: TRequest;

  Public
    Constructor Create();
    Function Login(SUsername: String; SEmail: String; SPassword: String): String;
End;

But when I add the unit to the uses of any of my forms I cant reference a class.

For Example: In Login_u I would like to add a variable called WebSystemInterface : TWebSystem problem is that it doesn't find either the TMobileSystem_u in the uses when I use crtl + space and it doesn't find the class when I declare it as a variable.

What could be wrong ? Does anyone know ?

** Edit

This is the output after attempting to compile the project

Checking project dependencies...
Compiling Exotic_Pets.dproj (Debug, Win32)
dcc command line for "Exotic_Pets.dpr"
  c:\program files (x86)\embarcadero\studio\14.0\bin\dcc32.exe -$O- -$W+ --no-config -M -Q -TX.exe -AGenerics.Collections=System.Generics.Collections;
  Generics.Defaults=System.Generics.Defaults;WinTypes=Winapi.Windows;WinProcs=Winapi.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE -DDEBUG 
  -E.\Win32\Debug -I"c:\program files (x86)\embarcadero\studio\14.0\lib\Win32\debug";"c:\program files (x86)\embarcadero\studio\14.0\lib\Win32\release";
  C:\Users\Jacques\Documents\Embarcadero\Studio\14.0\Imports;"c:\program files (x86)\embarcadero\studio\14.0\Imports";
  C:\Users\Public\Documents\Embarcadero\Studio\14.0\Dcp;"c:\program files (x86)\embarcadero\studio\14.0\include";"C:\Program Files 
  (x86)\Raize\CS5\Lib\RS-XE6\Win32" -LEC:\Users\Public\Documents\Embarcadero\Studio\14.0\Bpl -LNC:\Users\Public\Documents\Embarcadero\Studio\14.0\Dcp 
  -NU.\Win32\Debug -NSWinapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;System;Xml;Data;Datasnap;Web;Soap; -O"c:\program files 
  (x86)\embarcadero\studio\14.0\lib\Win32\release";C:\Users\Jacques\Documents\Embarcadero\Studio\14.0\Imports;"c:\program files 
  (x86)\embarcadero\studio\14.0\Imports";C:\Users\Public\Documents\Embarcadero\Studio\14.0\Dcp;"c:\program files (x86)\embarcadero\studio\14.0\include";
  "C:\Program Files (x86)\Raize\CS5\Lib\RS-XE6\Win32" -R"c:\program files (x86)\embarcadero\studio\14.0\lib\Win32\release";
  C:\Users\Jacques\Documents\Embarcadero\Studio\14.0\Imports;"c:\program files (x86)\embarcadero\studio\14.0\Imports";
  C:\Users\Public\Documents\Embarcadero\Studio\14.0\Dcp;"c:\program files (x86)\embarcadero\studio\14.0\include";"C:\Program Files 
  (x86)\Raize\CS5\Lib\RS-XE6\Win32" -U"c:\program files (x86)\embarcadero\studio\14.0\lib\Win32\debug";"c:\program files 
  (x86)\embarcadero\studio\14.0\lib\Win32\release";C:\Users\Jacques\Documents\Embarcadero\Studio\14.0\Imports;"c:\program files 
  (x86)\embarcadero\studio\14.0\Imports";C:\Users\Public\Documents\Embarcadero\Studio\14.0\Dcp;"c:\program files (x86)\embarcadero\studio\14.0\include";
  "C:\Program Files (x86)\Raize\CS5\Lib\RS-XE6\Win32" -V -VN -NBC:\Users\Public\Documents\Embarcadero\Studio\14.0\Dcp 
  -NHC:\Users\Public\Documents\Embarcadero\Studio\14.0\hpp -NO.\Win32\Debug   Exotic_Pets.dpr   
[dcc32 Error] Login_u.pas(39): E2003 Undeclared identifier: 'TWebSystem'
[dcc32 Fatal Error] Start_Interface_u.pas(43): F2063 Could not compile used unit 'Login_u.pas'
Failed
Elapsed time: 00:00:00.3
1
Are you possibly adding the TMobileSystem_u unit in the implementation uses clause and attempting to add a reference to TWebSystem in the Interface section? - Andy_D
@Andy_D - I'm adding the unit in the uses at the top because I would like to add the variable in the protected declarations of the form - user3564246
Silly question, but have you actually tried to compile the project or are you relying on Class Completion? - Andy_D
I've actually tried to compile the project then I get the error (See edited version of my question) - user3564246
Are all the source files in the same folder? Without seeing the code for Login_u it's difficult to know what's going on. Does the TMobileSystem_u unit compile in another project? - Andy_D

1 Answers

4
votes
  1. That happens if your units are in different folders and their paths are not set in DPR nor project "Search Paths".

  2. Ctrl+Space may not always suggest the full length of available units when used in uses section. I'd skip this clue.

  3. If you add unit into implementation section, you can not access it's constatnts/classes/etc prior to that (e.g. in TForm fields, types definitions and var sections)

  4. Classes declared in the implementation section can not be seen or accessed by other units.