CNV_FORMATTIMETMP

This procedure formats a time value, specified in TIME_ARY, according to a template, specified by TMP_ARY. The template can be retrieved for any convention from the CNV_TEMPLATE procedure. It can also be created by the user. The formatted time is returned in the language specified in LANG_NAME.

Example

This example formats a caller-supplied time, using a template also passed in by the calling program. Alphabetic time components are translated into English and returned in FT_ARY.

BEGIN

 $ INCLUDE INTL="*SYMBOL/INTL/ALGOL/PROPERTIES." 10000000 - 49999999
  FILE OUT(KIND=DISK,UNITS=CHARACTERS,MYUSE=IO,FILETYPE=0,NEWFILE,
           MAXRECSIZE=80,TITLE="OUT/ALGOL/CNVFMTTIMETMP.");
  DEFINE MAX_NAME_LEN        = 17#;    % Maximum length of convention
                                       % name
  EBCDIC ARRAY TMP_ARY[0:47], FT_ARY[0:44], TIME_ARY[0:9],
               LANG_NAME[0:MAX_NAME_LEN - 1];
  INTEGER FT_LEN, RESULT;

  REPLACE TIME_ARY BY "114958";
  REPLACE TMP_ARY BY "!T!!I!!M!!K!!S!!R!";
  REPLACE LANG_NAME BY "ENGLISH";
  RESULT := CNV_FORMATTIMETMP(TIME_ARY, TMP_ARY, LANG_NAME,
                              FT_LEN, FT_ARY);
  WRITE(OUT,<"RESULT = ",J4>,RESULT);
  IF RESULT EQL CS_DATAOKV THEN
    WRITE(OUT,<"FT_ARY = ",C45>,FT_ARY);
  CLOSE(OUT,LOCK);
END.

Output

RESULT = 1
FT_ARY = 11 hours 49 minutes 58 seconds

In this call, the parameters have the following meanings:

TIME_ARY is an EBCDIC array passed to the procedure. It contains the time to be formatted in the form HHMMSSPPPP. The partial seconds field, PPPP, is optional. The fields of the array have fixed positions. Blanks or zeros must be used in any fields that are omitted.

TMP_ARY is an EBCDIC array passed to the procedure in which the template to be used to format the time is specified. Refer to the MultiLingual System Administration, Operations, and Programming Guide for information about creating a template.

LANG_NAME is an EBCDIC array passed to the procedure. It contains the language to be used in formatting the time. If this parameter contains all blanks or zeros, the procedure uses the hierarchy to determine the language to be used. Refer to the MultiLingual System Administration, Operations, and Programming Guide for information about determining the valid language names on the system that is used by the program and the explanation of the hierarchy.

FT_LEN is an integer returned by the procedure. It contains the length of the formatted time.

FT_ARY is an EBCDIC array returned by the procedure. It contains the time value formatted according to the specified template and language.

RESULT is an integer returned by the procedure. This integer indicates whether an error occurred during the execution of the procedure. An explanation of the error result values and messages can be found at the end of this section.

The values returned by this procedure include:

CS_ARRAY_TOO_SMALLV (3001)

CS_BAD_TEMPLENV (3030)

CS_BAD_ARRAY_DESCRIPTIONV (3000)

CS_BADTIMEINPUTV (3013)

CS_BAD_DATA_LENV (3002)

CS_BAD_12HOURV (3052)

CS_BAD_HOURV (3051)

CS_DATAOKV (1)

CS_BAD_MINUTEV (3053)

CS_FAULTV (1001)

CS_BAD_PSECONDV (3055)

CS_FIELD_TRUNCATEDV (2003)

CS_BAD_SECONDV (3054)

CS_LANGUAGE_NOT_FOUNDV (2001)

CS_BAD_TEMPCHARV (3011)

CS_SOFTERRV (1002)