Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 158183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:38:11+00:00 2026-05-11T10:38:11+00:00

i’m using JCL’s expression evaluator TEvaluator (a marvelous creation donated by barry kelly). (THANK

  • 0

i’m using JCL’s expression evaluator TEvaluator (a marvelous creation donated by barry kelly). (THANK YOU barry!)

background

i’ve used the AddFunc method.

function MyFunc:double; begin   // calculations here   Result:=1;   end; 

you can use the AddFunc method to make the function available:

  AddFunc('MyFunc', MyFunc); 

here’s the problem…

i need to call a method on an object instead of a standalone routine.

the reason is that i have a list of objects that provide the values.

say we have a list of vehicle objects. each object has a Weight function. i want to be able to make available each object’s weight available for use in the formula.

a silly example but it’s easy to explain:

type   TVehicle=class   private   public     function Weight:double;   end;  function StrangeCalculation:double; var   vehicle:TVehicle; begin   for iVehicle = 0 to Count - 1 do     begin       vehicle:=GetVehicle(iVehicle);       // E2250 There is no overloaded version of 'AddFunc' that can be called with these arguments       eval.AddFunc(vehicle.Name, vehicle.Weight);     end;    Result:=eval.Evaluate('JeepTJWeight + FordF150Weight * 2'); end; 

my options:

  1. AddVar( ) or AddConst( ) — but that isn’t so great because i need to be able to raise an exception if the value is not available.

  2. AddFunc( ) with standalone functions. can’t do that because the names of (and number of) variables is unknown until runtime.

  3. modify the object to add a callback if the variable isn’t found. i have actually done this but needed to edit a copy of the source to call back to make it do this.

  4. make an AddFunc( ) that’s able to use method functions.

option #3 is actually built but an additional AddFunc would be nicer. the trouble is i don’t know what method prototype to provide. i thought TMethod would be the way but my knowledge is too limited here… here was my unsuccessful attempt but i still get ‘E2250 There is no overloaded version of ‘AddFunc’ that can be called with these arguments’ at the eval.AddFunc() call like before.

TFloat64MethodFunc = function(c:pointer): TFloat64;  procedure TEasyEvaluator.AddFunc(const AName: string; AFunc: TFloat64MethodFunc); begin   FOwnContext.Add(TExprFloat64MethodFuncSym.Create(AName, AFunc)); end;  TExprFloat64MethodFuncSym = class(TExprAbstractFuncSym) private   FFunc: TFloat64MethodFunc; public   constructor Create(const AIdent: string; AFunc: TFloat64MethodFunc);   function Evaluate: TFloat; override; // not using   function Compile: TExprNode; override; end; 

thank you for your help!

mp

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:38:12+00:00Added an answer on May 11, 2026 at 10:38 am

    figured it out…

    TFloat64MethodFunc = function: TFloat of object;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.