Conv-Time string converter

From Vectorlab
Jump to: navigation, search


Converts seconds to a time string.

{ convert seconds to a time string }
FUNCTION U_TimeStringConverter(seconds : LONGINT): STRING;
BEGIN
   U_TimeStringConverter :=	concat(
                concat(seconds DIV 3600), ':',
                concat((seconds MOD 3600) DIV 60), ':',
                concat((seconds MOD 3600) MOD 60)
                );
END;


Example
The following procedure prompts for an integer value. If a valid value is entered a dialog will display a time string:
PROCEDURE Test;
VAR
    secs: INTEGER;

    FUNCTION U_TimeStringConverter(seconds : LONGINT): STRING;
    BEGIN
       U_TimeStringConverter :=	concat(
                    concat(seconds DIV 3600), ':',
                    concat((seconds MOD 3600) DIV 60), ':',
                    concat((seconds MOD 3600) MOD 60)
                    );
    END;

BEGIN
    secs := IntDialog('Enter an integer value representing seconds:', '60');
    IF NOT didCancel THEN
        alrtDialog(U_TimeStringConverter(secs));
END;
Run(Test);