.Modelica.Utilities.Strings.Advanced.scanInteger

Information

Syntax

(nextIndex, integerNumber) = scanInteger(string, startIndex=1, unsigned=false);

Description

Starts scanning of "string" at position "startIndex". First skips white space and scans afterwards a signed number of type Integer. An Integer starts with an optional '+' or '-', immediately followed by a non-empty sequence of digits.

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

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

Note, a Real number, such as "123.4", is not treated as an Integer number and scanInteger will return nextIndex = startIndex in this case.

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 scanInteger
  extends Modelica.Icons.Function;
  input String string;
  input Integer startIndex(min = 1) = 1;
  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 Integer number "Value of Integer number";
end scanInteger;

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