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

special characters

special characters

Hi,
I need to pass a string to a external c-function under windows. The string contains special characters like \n for a new line. If I Write the characetr to a text file, the two characters \n appear in the text file (and not the expected new line).

My questions:
How does OpenModelica treat special characters like \n?
Which string would give me the new line?

Frank

Re: special characters

It depends what version of OMC you are using. Older versions of OMC would output \\n in some cases and \n in others (a bit arbitrarily).

As far as I know, putting a newline character in the Modelica string, i.e.

Code:

String str = "ab

c";

works for all OMC versions. If you found a certain way (read:bug) in which OMC 1.7 does not translate \n, post it and it will be fixed.

Re: special characters

Oh yea... The code I tested was:

Code:

model M

  function fn
    input String str;
    output Integer i;
  external "C" i=puts(str);
  end fn;
  Real x;
equation
  x = fn(String(time) + " ab\nc");
end M;

There are 0 guests and 0 other users also viewing this topic