views:

131

answers:

1

Lets say i wrote helper for TStringList

TslHelper = class helper for TStringList
  function DoSth: boolean;
end;

Then ive included this helper (unit in which helper is defined) in unit i want to use it. During debugging i hit Ctrl+F7 and i want to evaluate:

someStringList.DoSth

I cant get it to work. Is it possible?

Regards

+2  A: 

Class helpers introduce new methods into the current scope. If a class helper isn't in scope, then its methods do not take effect, even if the class they help is. So, the first step to making it work is to ensure that TslHelper is the class helper that would be in effect at the current point in your program.

If you've satisfied that requirement, but it still doesn't work, then perhaps the debugger simply doesn't recognize class helpers. They're a bit of a hack anyway, so I wouldn't be too surprised if the debugger didn't recognize them. Ultimately, class helpers are just syntactic sugar. The above class helper could have just as easily been written as a standalone function, like this:

function TStringList_DoSth(SL: TStringList): Boolean;

Write that function using your current implementation of the method, and then use the function to implement you class helper:

function TslHelper.DoSth: Boolean;
begin
  TStringList_DoSth(Self);
end;

You can continue to call the class-helper method in your normal code, but you can fall back to the standalone function in the debugger.

Rob Kennedy
actually i did just that ;]
m0f0