Solved

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

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

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…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

808 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