I use jQuery a lot. When passing a function to a jquery function, "this" is used to refere to the current object. Currently, I just use the asm section to access that variable. Is there a more elegant way?
jQuery(divMyTable, '#id-amount').each( procedure var this: Variant; amount: float; begin asm @this = this; end; //I would like to avoid using asm section regulary in my project. amount := TVariant.AsFloat(jQueryEx(this).text()); Inc(amount); jQueryEx(this).text(amount); end);
When I write a function, the this variable is used from a different scope. Inlining also doesn't help.
function W3This: variant; inline; function W3This: variant; begin asm @result = this; end; //Wrong scope end;