Solved

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

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now