Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Uses clause does not auto-update when adding components to a form


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Dec 17, 2014 2:34 PM Last Post By: ken skuse
ken skuse

Posts: 4
Registered: 10/29/06
Uses clause does not auto-update when adding components to a form  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 17, 2014 12:10 PM
Hi All

This is a bit of a long first post, but please stick with it. I wanted to include all the details and the background.

I've been programming for many many years, starting on PDP8's I got into Delphi with version 5, and later switched to the now ancient Turbo Delphi (fully registered legal copies on a Vista 32bit laptop and a W7 64bit desktop). These days, as a hobby programmer, it suffices for all my needs. However, Embarcadero invited me to trial the latest XE7, and the starter edition is reasonably priced so... a couple of weeks ago I decided that it really was time to upgrade and installed the 30 day trial copy of Delphi XE7. All went well, apart from exe's exploding from 400kB to 2.6MB from the same source, but thats not the issue.

I'd been playing with XE7 for about a week when I started the IDE to write a small data manipulation tool on the desktop machine. After I dropped some basic components on the form, I found the "uses" clauses wasn't updated, and things like Button1: TButton were underlined in red in the type clause reporting Undeclared Identifier. If I manually typed StdCtrls into the uses clause, everything was fine. Assuming it was some hiccup I thought "oh I'll just write it in Turbo for now", but when I tried to do that (on the same machine) it exhibited exactly the same behaviour. I went to try Turbo on the laptop and that behaved exactly the same as well.

Now here's the really weird bit: after a lot of messing about rolling back updates etc, and getting nowhere, I decided to restore a two year old disc image onto the desktop. This was Win 7 with a fully working Delphi Turbo. I included the mbr and track zero in the restore (to wipe any possible rootkit) as well as the System disc. Before exiting the restore program (Acronis, Linux based) I pulled the network cable so there would be no updates of either the OS or the antivirus. You can imagine my surprise when, after rebooting and starting up Delphi Turbo, it exhibited exactly the same problem - no auto additions to the uses clause when dropping a TButton on the form. I also tried moving the date back to one day after the image was made in case it was a date related issue, but that didn't fix it either.

So I have no idea what to try next. Two different versions of the software on the same machine, and a copy on a different machine no longer work as they used to, and an isolated restored previously working copy no longer working as it used to either - with exactly the same problem.

After much searching of the internet, I came up with two other reports of this;

http://embarcadero.newsgroups.archived.at/public.delphi.ide/201107/11073113731.html and

http://codeverge.com/embarcadero.delphi.ide/not-updating-uses-clause-when-a-new-co/1058790

Although the respondents try to say auto-updating of the Uses clause on dragging a component onto a form never happened in the first place, the original posters are convinced, as am I, that it did.

I should add that the workarounds noted in the replies in the first thread do work, but its just another un-necessary step I didn't have to take before. And most of all, I don't understand whats happened, and that bugs me.

Can anybody shed any light on whats going one here ?

Thanks - Ken S
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Uses clause does not auto-update when adding components to a form  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 17, 2014 12:39 PM   in response to: ken skuse in response to: ken skuse
ken skuse wrote:

I'd been playing with XE7 for about a week when I started the IDE to
write a small data manipulation tool on the desktop machine. After I
dropped some basic components on the form, I found the "uses" clauses
wasn't updated, and things like Button1: TButton were underlined in
red in the type clause reporting Undeclared Identifier. If I manually
typed StdCtrls into the uses clause, everything was fine. Assuming it
was some hiccup I thought "oh I'll just write it in Turbo for now",
but when I tried to do tha t (on the same machine) it exhibited
exactly the same behaviour. I went to try Turbo on the laptop and
that behaved exactly the same as well.

The IDE updates the uses clause when you save or compile the unit. It
has behaved this way for many versions back. XE7 is a bit less
aggressive than older versions in adding standard units like sysutils
or classes, though. You may run into cases were you need to add them
manually. But units containing the components you drop on the form are
always added when you save or compile.

--
Peter Below (TeamB)
Carl-Henrik Nil...

Posts: 53
Registered: 3/26/02
Re: Uses clause does not auto-update when adding components to a form  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 17, 2014 1:22 PM   in response to: ken skuse in response to: ken skuse
ken skuse wrote:
I'd been playing with XE7 for about a week when I started the IDE to
write a small data manipulation tool on the desktop machine. After I
dropped some basic components on the form, I found the "uses" clauses
wasn't updated, and things like Button1: TButton were underlined in
red in the type clause reporting Undeclared Identifier. If I manually
typed StdCtrls into the uses clause, everything was fine. Assuming it
was some hiccup I thought "oh I'll just write it in Turbo for now",
but when I tried to do tha t (on the same machine) it exhibited
exactly the same behaviour. I went to try Turbo on the laptop and
that behaved exactly the same as well.

Before I got D2005 I never noticed that the uses clause wasn't updated until the unit was saved.
The reason I became aware of it then was the red squiggly lines introduced by the new error insight.
Could it be that you had error insight turned off in your Turbo Delphi so you didn't notice?
Just a thought.
--
C-H
ken skuse

Posts: 4
Registered: 10/29/06
Re: Uses clause does not auto-update when adding components to a form  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 17, 2014 2:31 PM   in response to: ken skuse in response to: ken skuse
Thanks for the prompt replies.

I've been using Turbo Delphi reasonably regularly since September 2006 (I checked the registration email), I'm pretty sure that I would have noticed the red squiggly lines at some point in the past if they had been there, I noticed them immediately they appeared last week. They are blatently there in front of you in the type clause as soon as you switch to the code editor.

I agree the uses clause is now updated when you save or compile (it probably always checked at that point but I saw no change as the uses clause contained everything it was supposed to), or, if you have code complete turned on, when you reference a component property (eg Button1.Caption) or use CTRL+Space, but for myself, and the two posters in the threads that I noted, it has always updated the uses clause when components are dragged onto the form in the design window (tab), just as its predecessor Delphi v5 also did, with no errors displayed when switching to the code editor, until suddenly, for no reason, it doesn't. Indeed why would you design an IDE that didn't do that, it has all the information it needs to update the uses clause there and then.

I haven't made any changes to any settings. I just started the IDE and it behaved differently from last time I used it. It's not related to any updates or other software installed as evidenced by the isolated restore.

It may be that for the three of us the behavior we saw was an abnormal behavior, and what we have now is normal, but that doesn't explain why it has changed, and again for all three of us that change appears to have happened at some random point in time, but on every copy of every version we are running. Its not a major hassle, it just bugs me as to why its changed.

regards - ken s

Edited by: ken skuse on Dec 17, 2014 2:33 PM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02