// Initialize a string tag to hold the ":" character.
// Use ASCII definition of '58' to populate the tag
strColon.DATA[0] := 58;
strColon.LEN := 1;
// Initialze a string tag to hold a "0" character.
// Use ASCII definitiion of '48' to populate the tag
// Used for inserting a leading zero when needed.
strZero.DATA[0] := 48;
strZero.LEN := 1;
// Translate the time represented by seconds, into hours, minutes and seconds
// DINT place holders.
Hours := (timeInSeconds / 3600);
Minutes := (timeInSeconds / 60) - (Hours * 60);
Seconds := timeInSeconds - (Hours * 3600) - (Minutes * 60);
// Covnert DINT Hours into a string
DTOS(Hours,strHours);
// Check the string length, if 0 populate the hours
// string with "00"
IF strHours.LEN = 0 THEN
CONCAT(strZero,strZero,strHours);
// Prefix leading zero if the string length is only 1
ELSIF strHours.Len = 1 THEN
CONCAT(strZero,strHours,strHours);
End_If;
// Convert DINT minutes into a string
DTOS(Minutes,strMinutes);
// Check the string length, if 0 populate the minutes
// string with "00"
IF strMinutes.Len = 0 THEN
CONCAT(strZero,strZero,strMinutes);
// Prefix leading zero if the string length is only 1
ELSIF strMinutes.LEN = 1 THEN
CONCAT(strZero,strMinutes,strMinutes);
End_If;
// Convert DINT seconds into a string
DTOS(Seconds,strSeconds);
// Check the string length, if 0 populate the seconds
// string with "00"
IF strSeconds.LEN = 0 THEN
CONCAT(strZero,strZero,strSeconds);
// Prefix leading zero if the string length is only 1
ELSIF strSeconds.LEN = 1 THEN
CONCAT(strZero,strSeconds,strSeconds);
End_IF;
// Series of CONCAT statements to create the final
// "HH:MM:SS" format. Note, do not update the
// final timeHHMMSS tag until the entire string has been
// concatanated.
CONCAT(strHours,strColon,strJunk);
CONCAT(strJunk,strMinutes,strJunk);
CONCAT(strJunk,strColon,strJunk);
CONCAT(strJunk,strSeconds,timeHHMMSS);