TScrMemo...onHintForToken...

Hello,



Delphi XE. Version 6.5.2



I have moved to TScrMemo from TAdvMemo.



The callback OnHintForToken is not fired. I have searched for the cause in my code and no joy. The event is set in the object inspector and placing a breakpoint in the code, it never stops when the mouse is over a token. I want to see the value of the token. It has worked for years with TAdvMemo. Not sure what I have done wrong or what has changed.



Also when debugging code and selecting to step over a line the memo has a bad habit of scrolling the line to the top of the memo. Very annoying and I can not find a property to set to stop it. Maybe I am missing something. It does not do it every time.



Regards,



Mark

Hello,


TScrMemo is exactly like TAdvMemo, only names were changed, that's the only difference. So I'm not sure about what are you comparing to. Maybe you used an old version of TAdvMemo? Can you please maybe create a project that illustrates and reproduces the issues you are having and send it to us so we can check?
Do you also have TAdvMemo installed or only TScrMemo?

Hello,



When the mouse is over a token the hint window should appear, after X time, and give the value of the token if the script is running.



Right???



Yes, I have TAdvMemo installed. I have the TMS component pack.



When I looked in the TMS code, at the code that calls OnHintForToken, the OnHintForToken property was always nil. The object inspector says it is not nil.



Mark

I suggest you send a project reproducing the problem for our support e-mail.


Maybe we can do this faster, using any demo that comes with the installer.



What calls OnHintForToken? I am using the IDE code that came with Scripter before the name change and it uses OnHintForToken to show the value of a token during debugging via the



v := EvaluateWatch(atPascalScripter1,AValue);



call.



I opened the debugger demo project that comes with the latest version, I added a callback in the object inspector.



procedure TForm1.ScrMemo1HintForToken(Sender: TObject; X, Y: Integer;

AValue: string; var AHint: string; var Show: Boolean);

begin

beep;

end;



set a break point, the code stopped on the breakpoint. Moving the mouse, over tokens, this event never fired.









In that demo you just need to set:


  scrMemo1.ShowHint := true;
 
to show the hint.

Hello,



Very good. Now when debugging and the mouse moves over a token, I get an exception when



Show := atMemoInterface2.GetTokenHint(AValue,AHint);



is called.       AValue and AHint contain the name of the token.



EvariantInvalidOpError with message Invalid variant operation.



Mark



Add on.



I stepped into the code:



function TatMemoInterface.GetTokenHint(AToken: string; var AHint: string): boolean;



    v := EvaluateWatch(Scripter,AToken);



returns a variant array of variant



the next line:



result:=v<>null



cause the error. EvariantInvalidOpError with message Invalid variant operation.





That's expected and is the script engine trying to evaluate the token. The exception is ignored.



That cannot work.

I am confused.

The token value is never determined because the function exits (because of the exception) without executing the code to get the value of the token.

    Show := (v <> null);       <-------------------EXITS HERE

NOTHING BELOW HERE EXECUTED

    if (v <> null) then
    begin
      s := v;
      AHint := 'value = ' + s;
      vt := vartype(v);
      case vt of
      varInteger: AHint := AHint + ': integer';
      varDouble: AHint := AHint + ': double';
      varString: AHint := AHint + ': string';
      varByte: AHint := AHint + ': byte';
      {$IFDEF DELPHI6_LVL}
      varWord: AHint := AHint + ': word';
      {$ENDIF}
      varBoolean: AHint := AHint + ': boolean';
      varDate: AHint := AHint + ': TDateTime';
      varArray: AHint := AHint + ': array';
      end;
    end;
except
end;

Hmmmm.



Ignore my last.



Thanks for your help.