Page 1 of 1

call a function in the Function Editor

Posted: Thursday 28 November, 2013 - 11:04
by manuel
Hi,

I´m trying to call a function in a Function Editor with another function in the same Function Editor. It works properly, but if I save my model and open it again there is an error saying the function is not a valid expression. If I open the functions again and press OK the error is gone and i can continue my work. I got many of this functions and everytime my model is crashing I need several minutes to fix this problem. Has anyone a idea how to fix it?

Thanks a lot.
Manuel

Re: call a function in the Function Editor

Posted: Thursday 28 November, 2013 - 17:37
by marlies
Hi Manual,

That is because of the sequence of registration. This is the sequence in which they are shown in the function editor. What you could do to solve this:

- Use the command PreregisterFunction(p1,p2,p3) in the oninit event handler of an atom that is higher in rank than the function editor to preregister the function.
- Add another function editor to your model, which you use to registrate the functions that make use of functions in the first editor.
- Or make sure that the sequence in the 1st function editor is according to the required registration sequence.

Regards, Marlies

Re: call a function in the Function Editor

Posted: Friday 29 November, 2013 - 12:02
by manuel
thanks, it works now :-)

Another question: is there any possibility to end an infinite loop?
In Plant Simulation the infinite loop is stopped if you press three buttons on the keyboard.
Is there any similar option in ED?

Re: call a function in the Function Editor

Posted: Wednesday 04 December, 2013 - 10:52
by marlies
Hi Manuel,

I am afraid that once you're in the infinite loop the only solution is ctrl+alt+delete.

To check why your code is getting into this infinite loop, I would suggest to add the command enterdebugger(1) in your code and step through the code to find out what's going wrong.

Besides that it's always good to limit your loops. The command loopuntil for example has a parameter that defines the maximum number to execute, the loop will stop even when the criterium isn't reached.

Regards, Marlies

Re: call a function in the Function Editor

Posted: Friday 07 February, 2014 - 08:27
by schepers
Hello,
is there any solution for recursion? When I try to implement a recursion, only fault is unreg. function.
Thx,
Schepers

Re: call a function in the Function Editor

Posted: Monday 17 February, 2014 - 12:07
by marlies
Hello Schepers,

It should be no problem to implement a recursion as long as you make sure that your code is not triggering infinite loops.

What do you mean by: only fault is unreg. function? Do you get an error message? And if so, what did you implement and when do you get the error message?

Regards, Marlies