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

Usage of print() inside functions in 1.18.0

Usage of print() inside functions in 1.18.0

Hi,

during development I like to use print() statements inside functions to display variables and parameters in order to help with debugging.
However, after moving from Openmodelica 1.17.x to 1.18.0 print() statements in functions seem to be ignored as there is no output written. Writing to stdout or files does not make a difference.

From inside models it is working fine.
Please find attached a small sample showing the issue.

I am running the current stable release 64bit on Windows 10.
Is this a problem with 1.18.0? What am I doing wrong?

--Philipp

test.mo

Edited by: PHG - Oct-18-21 07:38:47
Attachments:

Re: Usage of print() inside functions in 1.18.0

You need to make the input not be a constant or OMC evaluates the function at compile-time. If you pass x*time to square, the results are printed.

Re: Usage of print() inside functions in 1.18.0

Thank you very much for your fast and helpful reply.
I am now using your suggestion of passing time variable as a workaround

I wasn't aware that using constants in a function results in it being evaluated at compile-time only.

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