Recent

Author Topic: (Solved)Reacuring problem with use clause  (Read 280 times)

JLWest

  • Hero Member
  • *****
  • Posts: 987
(Solved)Reacuring problem with use clause
« on: November 19, 2020, 11:39:10 pm »
I have a program with 1 form and two units;I get an error that Unit2 can't be found.
I have a backup of unit2. It is a static code unit so I copy it back in to development dir. It just started all of a sudden. happened twice.

 
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Buttons,  clipbrd,  Classes,   Controls,
  9.   Dialogs,  ExtCtrls, FileUtil,  Forms,
  10.   Graphics, SysUtils, StrUtils,  StdCtrls,
  11.   Spin,     Types;                                    
  12.  
  13.                    
  14.  
  15. implementation
  16.  
  17. {$R *.lfm}
  18.  
  19. Uses Unit2;        // <== keeps diapering.
  20.  
  21.  
  22.  

« Last Edit: November 20, 2020, 01:59:58 am by JLWest »
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

winni

  • Hero Member
  • *****
  • Posts: 2113
Re: Reacuring problem with use clause
« Reply #1 on: November 20, 2020, 12:53:26 am »
Hmmmm - strange.

Whatever happend:

Open unit2 in the IDE.
Menu --> Project --> Add File in Editor to project (Shift F11 by default).

Winni

jamie

  • Hero Member
  • *****
  • Posts: 4030
Re: Reacuring problem with use clause
« Reply #2 on: November 20, 2020, 01:26:37 am »
I think he has another copy of the file elsewhere in the path without the unit in the list and it keeps reloading it.

copying a file over during a session with a unit file of the same name still open is not really a good idea
The only true wisdom is knowing you know nothing

JLWest

  • Hero Member
  • *****
  • Posts: 987
Re: Reacuring problem with use clause
« Reply #3 on: November 20, 2020, 01:59:35 am »
Found the problem I think.

There is a sub-dir that is emptied during start out of formcreate. So I load the directory with findallfiles. The path to the sub-directory wasn't set, blank in fact and it loaded the development dir and deleted all my files except the exe file. i guess because it was open. I did have a very recent backup of the entire directory. So I restored.

Changing that process to DirectoryExists, DelDirectory, MakDir. 

 
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

 

TinyPortal © 2005-2018