.Modelica.Utilities.Strings.Advanced.scanReal

Information

Syntax

(nextIndex, realNumber) = scanReal(string, startIndex=1, unsigned=false);

Description

Starts scanning of "string" at position "startIndex". First skips white space and scans afterwards a number of type Real with an optional sign according to the Modelica grammar:

real     ::= [sign] unsigned [fraction] [exponent]
sign     ::= '+' | '-'
unsigned ::= digit [unsigned]
fraction ::= '.' [unsigned]
exponent ::= ('e' | 'E') [sign] unsigned
digit    ::= '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'

If successful, the function returns nextIndex = index of character directly after the found real number, as well as the value in the second output argument.

If not successful, on return nextIndex = startIndex and the second output argument is zero.

If the optional argument "unsigned" is true, the number shall not start with '+' or '-'. The default of "unsigned" is false.

See also

Strings.Advanced.

Interface

pure function scanReal
  extends Modelica.Icons.Function;
  input String string;
  input Integer startIndex(min = 1) = 1 "Index where scanning starts";
  input Boolean unsigned = false "= true, if number shall not start with '+' or '-'";
  output Integer nextIndex "Index after the found token (success=true) or index at which scanning failed (success=false)";
  output Real number "Value of Real number";
end scanReal;

Generated at 2024-11-23T19:25:52Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos