Variable function name - EVALUATE

Hi all ! Does anyone have an idea of how can i call a function from a codeunit, but having the function’s name in a variable ? I tried this using the EVALUATE function, but EVALUATE doesn’t work as i expected. Here is a short example to demonstrate what i’m talking about: The codeunit 1 (App. Management) contains the function ApplicationVersion which returns a string. The piece of code below calls the function twice. First time directly, second time indirectly. VAR tmpbool : Boolean; code1 : Codeunit 1; result: Text[50]; tmpbool := EVALUATE(result, ‘code1.ApplicationVersion’) ; MESSAGE(’%1%2’, code1.ApplicationVersion, result); Notice that the second line of message box is “code1.ApplicationVersion” instead of “W1 2.60.D” (my ver.) Any sugestion? Thanks in advance

VAR CU1 : codeunit 1 Result : Text[50] Code Result := CU1.ApplicationVersion; Message(Result); should do the trick Lars Strøm Valsted ------------------------- Why can’t programmers tell the difference between Christmas and Halloween? Because OCT(31) = DEC(25)

Lars, The message box in the example is only to see the result of the demo. My problem is not how to display a value, but how to call a function whose name is not known at compile time. I want to decide at run time what function to call (by reading its name in from a table). I’m sorry i was not more specific in the first message. Best regards. PS. Your signature is cool. I LOL with all my colleagues.

Hi Popa, To call a function whose name is not known at compile time is, as far as I know not possible in Financials/Attain. Lars Strøm Valsted ------------------------- Why can’t programmers tell the difference between Christmas and Halloween? Because OCT(31) = DEC(25)

Hi Popa, EVALUATE(result, ‘code1.ApplicationVersion’) ; fills result with the string ‘code1.ApplicationVersion’. I mean, with the ’ is not an object, but a string, so the result you obtain is right. Try without the ’ . If you want to use EVALUATE() like the java EVAL() , you’ re wrong :slight_smile: EVALUATE() in C/AL is used to swith values between data types. Bye.

To call a codeunit dynamically in Navision, you will need to have some method of determaining which codeunit to run. If you can get the number from the Object table for example, you can create a variable of Integer type and simply do a Codeunit.RUN(YourCodeUnitNbr) If you already know which codeunit to run but, want a certain function in the codeunit, it’s a little more tricky but can be done, you can checkout the Calculation Methods in Payroll to see how this is done. Bill Benefiel Manager of Information Systems Overhead Door Company billb@ohdindy.com (317) 842-7444 ext 117

William, Only in the US is Payroll a part of the standard product. In all other countries it is a country-specific add-on. Lars Strøm Valsted ------------------------- Why can’t programmers tell the difference between Christmas and Halloween? Because OCT(31) = DEC(25)