Recent

Author Topic: when do i use : Unused(ATool, APoint)  (Read 3285 times)

frederic

  • Full Member
  • ***
  • Posts: 226
when do i use : Unused(ATool, APoint)
« on: March 01, 2017, 12:29:15 pm »
dear specialists

may be a stupid question, but i like to understand the function "Unused(ATool, APoint)

i see it is been used in
-DataPointClickTool1PointClick(  ATool: TChartTool; APoint: TPoint);
-DataPointHintTool1Hint(ATool: TDataPointHintTool;  const APoint: TPoint; var AHint: String);     

and mayb e in some other tools as well     

What exactly happens then

frederic         


jacmoe

  • Full Member
  • ***
  • Posts: 249
    • Jacmoe's Cyber SoapBox
Re: when do i use : Unused(ATool, APoint)
« Reply #1 on: March 01, 2017, 12:40:18 pm »
I don't know, but my qualified guess would be that it exists for the purpose of shutting up the compiler so that it does not complain about unused variables. :)

more signal - less noise

frederic

  • Full Member
  • ***
  • Posts: 226
Re: when do i use : Unused(ATool, APoint)
« Reply #2 on: March 01, 2017, 02:15:00 pm »
oke ,but which unused variables?

for a datapointclicktool  i have already the tool and for clicking i have the coordinates of the point  or...
 refers ' unused"to coordinates which are too far away from the meant datapoint and therefore not relevant?
 
But what  happens  then?

frederic

wp

  • Hero Member
  • *****
  • Posts: 11856
Re: when do i use : Unused(ATool, APoint)
« Reply #3 on: March 01, 2017, 06:16:24 pm »
"Unused()" is a helper procedure written by the "fathers" of TACharts in order to silence the compiler if a parameter passed to a procedure is not used. Suppose you write a handler to a button OnClick event, it is supposed to show a message:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender. TObject);
  2. begin
  3.   ShowMessage('Button1 was clicked');
  4. end;
This works fine, but when you look at the message window after compilation you will see a message saying that parameter Ssnder is not used by the procedure Button1Click. This is a hint that the parameter could have a real, important meaning and you just forgot to call it. Of course, this is not true here, and the hint is a false alarm. In order to keep the message window free for "real" hints and warnings you can call the procedure Unused with the parameter Sender. This procedure does not do anything, it just has the parameter in its parameter list, and therefor the parameter is no longer "unused" by the calling procedure Button1Click.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender. TObject);
  2. begin
  3.   Unused(Sender);
  4.   ShowMessage('Button1 was clicked');
  5. end;

Another method would have been to right-click on the hint in the message window and select "Hide message by inserting IDE directive {%H]". I don't know why the inventors of TAChart did not choose this "official" way, maybe this directive did not exist in those days.

frederic

  • Full Member
  • ***
  • Posts: 226
Re: when do i use : Unused(ATool, APoint)
« Reply #4 on: March 02, 2017, 04:17:10 pm »
i understand

thanks

 

TinyPortal © 2005-2018