ESPL: Mouse command example


Q:  I'm learning how to use mouse function in my script.  I tried using the following example code from the ESPL help documentation but it does not work. Is there something else that I must do before mouse function could work?  It appears like the  MOUSE  command in ESPL is not working.

EXAMPLE:  The following program opens an IBM daily chart.  The program should report the Last price of the selected bar, whenever the mouse is clicked on the chart.  Click near the left edge of the chart to stop the program.

var
    x,y,zLast: integer;
    Msg:string;
begin
    Chart('IBM.D');
    repeat
       if Mouse(x,y) then
       begin
         zLast:=Bar(eClose,XtoIndex(X));
         Msg:='Last = ' + FormatPrice(IntToStr(zLast),True) + '   ';
         TextOut(100,20,Msg);
       end;
       Application.ProcessMessages;
    until (X<20);
end;

A:  The example is testing the mouse location at all times and the mouse X value prior to moving onto the chart is returning a Zero value which stops the Repeat loop.   Solution is to edit the Until line to be this:

  until  (X>0) and (X<20);

Then the example works as intended.  Click the RUN button.  On the chart click at various places and the Message will show.   If you move near the left edge the routine stops because X location will be <20.


charting software | features | downloads | order | help | search | testimonials | disclosures | contact us | Ensign charts on FacebookEnsign charts on twitterEnsign charts on You Tube
Ensign Software, Inc., 113 Stillwater Drive, Idaho Falls, ID 83404 Support: 801-328-1382 Billing: 208-552-2230
(c) 2011 Ensign Software, Inc. All Rights Reserved
Last modified 1/31/08 1:44 PM