Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

optional input for 'record'

optional input for 'record'

Hey all,

So I am implementing a caching mechanism. Modelica does not have global variable so I need to pass this cache around. However, I want this cache input to be optional in a function, like

function tempFunc
   input Cache cache = NULL;
end tempFunc;

But Modelica does not have NULL. Any suggestion? Thank you!

Re: optional input for 'record'

Can you use external objects for this?

Re: optional input for 'record'

Thank you! I saw External Object before but thought it were some kind of interface between Modelica and C. I did not know that ExternalObject can act as a global variable in Modelica.

Re: optional input for 'record'

Actually, ExternalObject does not help. For example, in the following code, I want to call test(5) with no input for 'obj' but what should be the default value for the 'obj'?

Code:


function test
   input Integer N;
   input ExtObj obj = ???;
algorithm
end test;

class TestModel
algorithm
    test(5)
end TestModel;

Edited by: cvan - Jul-14-17 12:37:34

Re: optional input for 'record'

Modelica has variables of type "inner" and "outer" which can work as global variables inside a package.
If you could elaborate a little more maybe a better solution an be suggested.

There are 0 guests and 0 other users also viewing this topic
You are here: