Solved

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

Posted on 2004-09-17
4
136 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
  • 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 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