It is not recommended to use global variables or external objects in Modelica functions. Instead, pass them as additional parameters.
Reasons - Global variables break the mathematical function property that a function called with the same argument values always return the same results - Modelica compilers can reorder function calls by symbolic manipulation. If you use global variables, bugs can appear. - you models become less understandable with global variables. Peer F -----Original Message----- From: owner-openmodelicainter...@ida.liu.se [mailto:owner-openmodelicainter...@ida.liu.se] On Behalf Of Emil Larsson Sent: den 18 december 2012 11:42 To: OpenModelicaInterest@ida.liu.se Subject: Global variables inside a Modelica function? Hi, does anyone know if it is possible to define global variables inside a Modelica function? Using the inner/outer concept does not work for functions, or? Does anyone have an idea how I can solve the problem of accessing environment variables inside a function without having to send these variables as input arguments to each function? Best regards, Emil -- ----------------------------------------------------------------- Emil Larsson, Ph.D. Student e-mail: l...@isy.liu.se Division of Vehicular Systems phone: +46 (0)13-28 57 13 Department of Electrical Engineering fax: +46 (0)13-28 20 35 Linköping University S-581 83 Linköping, SWEDEN