Solved

Why does Autcomplete work for assignemt (a:=b) but not for comparison (a=b)?

Posted on 2004-09-17
4
137 Views
Last Modified: 2010-04-05




If I'm using AutoComplete (or code sense? ) where it gives a list of
possible variables that can complete a command:

If I am making an ASSIGNMENT (Varabile:=....) then auto complete works
with sys constants like clRed, etc.

If I am making a COMPARISON (if Variable=...) then ac does NOT work with
clRED, vk_RETURN, etc.

Anyone know why this is?

TIA!

0
Comment
Question by:clay111296
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 50 total points
ID: 12089157
Probably because the just-in-time compilation isn't as smart as the real compiler. If you use a writeln statement to write to a text file, you could notice something similar. The problem is probable that Delphi just can't determine what variable or type would be valid in this location.
0
 

Author Comment

by:clay111296
ID: 12098770
So, are you saying that the compiler is smarter about ASSIGNMENT statments than it is about COMPARISON statements?

Also, I've tried defining a variable as ColorRef so the compiler KNOWS the variable data type.


EXAMPLE:
var
  clColor: COLORREF;

  begin
  clcolor:=clBlue;  //ON THIS LINE I *DO* GET AUTOCOMPLETE HELP

  if clColor=xy then ShowMessage('it worked');  //ON THIS LINE I DO *NOT* GET AUTOCOMPLETE HELP.

AND YET, I DON'T GET AUTO COMPLETE HELP AFTER THE "=" SIGN.


WORKS IN D6 BUT NOT IN DELPHI 8.

This may be due to an addin called Castalia. Need to test more.


0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12100233
Yep, the compiler is smarter with ASSIGNMENTS because it knows which type to expect. With comparisons, it's a bit more complicated.

Hmmm. Maybe it's related because in your example, one variable is called "Varabile" and the other is called. "Variable". ;-)

I have tried in Delphi 5, though. Code completion with comparisons are a bit mixed up. I could get the Autocomplete combobox bt pressting <CTRL><SPACE> but eben then it does not find the clBlue or other color constant that I want.

The reason seems to be that the background compiler has less problems with assignments than comparisons. That''s all, it seems.
0
 

Author Comment

by:clay111296
ID: 12103643

Further testing with D7


if I do :
clColor=clR     >>>> I get  choices that autocomplete it (clRed, etc.)

If I do
IF clColor=clR  >>>>  I do NOT get choices that autcomplete.

In Delphi 8 (for .net)
I get choices in both cases.

CASTALIA NOT THE CAUSE
Same results with or without Castalia.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question