### Author Topic: Funktion: FormatTime\$  (Read 2666 times)

#### Alexander

• Guest
##### Funktion: FormatTime\$
« on: 2005-Aug-08 »
Hi,

hier eine kleine Funktion zum Anzeigen einer Zeit

Code: (glbasic) [Select]
`// --------------------------------- //// Project: FormatTime// Start: Monday, August 08, 2005// IDE Version: 2.50727LET StartTime = GETTIMERALL() / 1000WHILE 1  LET Zeit = (GETTIMERALL() / 1000) - StartTime  PRINT FormatTime\$(Zeit), 10, 10  SHOWSCREENWEND// ------------------------------------------------------------- //// -=#  FORMATTIME  #=-// ------------------------------------------------------------- //FUNCTION FormatTime\$: ftSeconds    LET ftTime\$ = FORMAT\$(2, 2, (ftSeconds / 60))    SPLITSTR(ftTime\$, ftArray\$[], ".")    IF ftArray\$[1] <> "00"      LET ftMin = ftArray\$[0]      LET ftSec = FORMAT\$(1, 0, (ftSeconds - (ftMin * 60)))            IF ftSec = 60        LET ftSec = 0        LET ftMin = ftMin + 1      ENDIF      IF ftSec < 10        LET ftSec\$ = "0" + ftSec      ELSE        LET ftSec\$ = ftSec      ENDIF      LET ftTime\$ = FORMAT\$(2, 0, ftMin) + ":" + ftSec\$        ELSE      LET ftTime\$ = FORMAT\$(2, 0, ftArray\$[0]) + ":" + ftArray\$[1]      ENDIF    RETURN ftTime\$ENDFUNCTION // FORMATTIME`