index

Varkon MBS Programmers manual

# str - Function

## Description

Converts an int or float value to a string of characters with optional formatting.

## Syntax

      s:=str(number, width, precision);

      string    s;
      int/float number;
      int       width;
      int       precision;

## Principal parameters

number | - The int or float value to convert.

## Optional parameters

width | - The number of character positions that will be used.
| - If width is negative, characters will be left justified.
| - If width is positive, characters will be right justified.
| - If width is less than the characters needed, it is automatically increased.
| - If width is larger than the characters needed, spaces are added.
precision | - Controls the number of decimal places. A value of -1 gives E-notation.

## Return value

A STRING value equal to the result of the conversion.

## Examples

      s:=str(12345,1,0);     ! Eeual to s:="12345";
      s:=str(12345,10,0);    ! Equal to s:="     12345";
      s:=str(12345,-10,0);   ! Equal to s:="12345     ";
      s:=str(12345,-10,2);   ! Equal to s:="12345.00  ":
      s:=str(12345,-15,-1);  ! Equal to s:="1.234500e+04   ":
      s:="PI="+str(pi,1,5);  ! Equal to s:="PI=3.14159";

## See also

rstr()

Varkon version 1.19C svn# 120