Sage-ST ä

Convert

Documentation

Global Declarations (Constants, Types, Variables)
CardToPercent CardToStr IntToStr
LongIntToStr NumToStr NumberToRoman RomanToNumber
StrToCard StrToInt StrToLongInt StrToNum





  CONST
    MaxBase = 16;

  TYPE
    BaseType = [2 .. MaxBase];




  PROCEDURE IntToStr
             (CONST int     : INTEGER;
              VAR   Str     : ARRAY OF CHAR;
              CONST width   : CARDINAL;
              VAR   Success : BOOLEAN);

  (**
      IntToStr - Convert INTEGER to string, can be a fixed size.

      This procedure converts an INTEGER into a string that represents the
      number.  There are two modes of using this routine.  If the value of
      width is equal to 0 then the value is converted to string in a free
      format.  If the value of width is greater than 0 the string is converted
      in a fixed format.

      Free format - If the value of width is 0 then this format is used.  This
      results in a string that is always left justified and only shows the sign
      position if the number is negative.  In this mode the only constraint to
      converting is the size of the string that was passed in.

      Fixed format - If the value of width is greater than 0 then this format is
      used.  In this mode the value is converted to a total length that equals
      the size of width.  NOTE - The value of width INCLUDES the sign character
      if the number is negative (i.e. the value of -100 requires a width of 4).
      If the value is positive it can completely fill the string (i.e. a width
      of 4 can handle a positive value up to 9999).

      If the string passed is shorter than width or if the converted value will
      not fit within the length of the string then SageError #16
      (SageErrs.ArrayTooSmall) is generated.
  *)




  PROCEDURE LongIntToStr
             (CONST int     : ModSys.INT32;
              VAR   Str     : ARRAY OF CHAR;
              CONST width   : CARDINAL;
              VAR   Success : BOOLEAN);

  (**
      IntToStr - Convert INTEGER to string, can be a fixed size.

      This procedure converts a Long INTEGER into a string that represents the
      number.  There are two modes of using this routine.  If the value of
      width is equal to 0 then the value is converted to string in a free
      format.  If the value of width is greater than 0 the string is converted
      in a fixed format.

      Free format - If the value of width is 0 then this format is used.  This
      results in a string that is always left justified and only shows the sign
      position if the number is negative.  In this mode the only constraint to
      converting is the size of the string that was passed in.

      Fixed format - If the value of width is greater than 0 then this format is
      used.  In this mode the value is converted to a total length that equals
      the size of width.  NOTE - The value of width INCLUDES the sign character
      if the number is negative (i.e. the value of -100 requires a width of 4).
      If the value is positive it can completely fill the string (i.e. a width
      of 4 can handle a positive value up to 9999).

      If the string passed is shorter than width or if the converted value will
      not fit within the length of the string then SageError #16
      (SageErrs.ArrayTooSmall) is generated.
  *)




  PROCEDURE CardToStr
             (CONST card    : CARDINAL;
              VAR   Str     : ARRAY OF CHAR;
              CONST width   : CARDINAL;
              VAR   Success : BOOLEAN);

  (**
      CardToStr - Convert CARDINAL to string, can be a fixed size.

      This procedure converts a CARDINAL into a string that represents the
      number.  There are two modes of using this routine.  If the value of
      width is equal to 0 then the value is converted to string in a free
      format.  If the value of width is greater than 0 the string is converted
      in a fixed format.

      Free format - If the value of width is 0 then this format is used.  This
      results in a string that is always left justified.  In this mode the only
      constraint to converting is the size of the string that was passed in.

      Fixed format - If the value of width is greater than 0 then this format is
      used.  In this mode the value is converted to a total length that equals
      the size of width (i.e. a width of 4 can handle a value up to 9999).

      If the string passed is shorter than width or if the converted value will
      not fit within the length of the string then SageError #16
      (SageErrs.ArrayTooSmall) is generated.
  *)




  PROCEDURE NumToStr
             (CONST Num     : CARDINAL;
              VAR   Str     : ARRAY OF CHAR;
              CONST base    : BaseType;    (* [2 .. 36] *)
              CONST width   : CARDINAL;
              VAR   Success : BOOLEAN);

  (**
      NumToStr - Convert CARDINAL to string, can be a fixed size.

      This procedure converts a CARDINAL into a string that represents the
      number in the requested base.  There are two modes of using this routine.
      If the value of width is equal to 0 then the value is converted to string
      in a free format.  If the value of width is greater than 0 the string is
      converted in a fixed format.

      Free format - If the value of width is 0 then this format is used.  This
      results in a string that is always left justified.  In this mode the only
      constraint to converting is the size of the string that was passed in.

      Fixed format - If the value of width is greater than 0 then this format is
      used.  In this mode the value is converted to a total length that equals
      the size of width (i.e. a width of 4 can handle a value up to 9999).

      If the string passed is shorter than width or if the converted value will
      not fit within the length of the string then SageError #16
      (SageErrs.ArrayTooSmall) is generated.
  *)




  PROCEDURE StrToInt
             (CONST Str     : ARRAY OF CHAR;
              VAR   int     : INTEGER;
              VAR   Success : BOOLEAN);




  PROCEDURE StrToLongInt
             (CONST Str     : ARRAY OF CHAR;
              VAR   int     : ModSys.INT32;
              VAR   Success : BOOLEAN);




  PROCEDURE StrToCard
             (CONST Str     : ARRAY OF CHAR;
              VAR   card    : CARDINAL;
              VAR   Success : BOOLEAN);




  PROCEDURE StrToNum
             (CONST Str     : ARRAY OF CHAR;
              VAR   Num     : CARDINAL;
              CONST base    : BaseType;    (* [2 .. 36] *)
              VAR   Success : BOOLEAN);




  PROCEDURE NumberToRoman
             (CONST Number   : CARDINAL;
              VAR   RomanStr : ARRAY OF CHAR;
              VAR   Success  : BOOLEAN);




  PROCEDURE RomanToNumber
             (CONST RomanStr : ARRAY OF CHAR;
              VAR   Number   : CARDINAL;
              VAR   Success  : BOOLEAN);




  PROCEDURE CardToPercent
             (CONST CardValue   : CARDINAL;
              CONST TotalValue  : CARDINAL;
              VAR   CardPercent : CARDINAL;
              VAR   StrPercent  : ARRAY OF CHAR);

  (**
      CardToPercent - Calculate and return the percent that a number is.
  *)




Send mail to   warren.merrill@inl.gov with questions or comments about this web site.
Copyright © 1989-2006 Battelle Energy Alliance