' *** TIME_INP.LST *** 2nd GFA-Manual, page 3-11 > PROCEDURE time_input(VAR time.inp\$) ' ' *** Enter time at current cursor-position (seconds not necessary) ' *** Accepts different formats: 12.40.10 1:30:25 20.45 ' *** After checking for errors, the time is returned as "hh:mm:ss" ' *** Procedure uses ERROR for catching unexpected errors ' ' *** Procedure: Program_error Iime_input_error ' LOCAL x,y,ok!,time.input\$,hour.len,hour\$,minute.input\$,minute.len LOCAL minute\$,second\$,second.input\$,second.len x=CRSCOL y=CRSLIN ON ERROR GOSUB time_input_error ' time.input: ' *** Time input ok!=TRUE FORM INPUT 10,time.input\$ ' *** Hours hour.len=VAL?(time.input\$) IF hour.len>2 ! for format 12.30.00 IF INSTR(time.input\$,".")=2 hour.len=1 ELSE IF INSTR(time.input\$,".")=3 hour.len=2 ELSE ok!=FALSE ENDIF ENDIF ENDIF hour\$=LEFT\$(time.input\$,hour.len) IF VAL(hour\$)>23 ok!=FALSE ENDIF ' *** Minutes LET minute.input\$=RIGHT\$(time.input\$,LEN(time.input\$)-(hour.len+1)) LET minute.len=VAL?(minute.input\$) IF minute.len>2 ! for format 12.30.00 IF INSTR(minute.input\$,".")=2 LET minute.len=1 ELSE IF INSTR(minute.input\$,".")=3 LET minute.len=2 ELSE ok!=FALSE ENDIF ENDIF ENDIF LET minute\$=LEFT\$(minute.input\$,minute.len) IF VAL(minute\$)>59 ok!=FALSE ENDIF ' *** Seconds IF minute.len>=LEN(minute.input\$)-1 second\$="00" ELSE second.input\$=RIGHT\$(minute.input\$,LEN(minute.input\$)-(minute.len+1)) second\$=LEFT\$(second.input\$,2) IF VAL(second\$)>59 ok!=FALSE ENDIF ENDIF ' *** Time IF NOT ok! PRINT CHR\$(7); PRINT AT(x,y);STRING\$(LEN(time.input\$)," "); PRINT AT(x,y);"WRONG !!"; PAUSE 50 PRINT AT(x,y);STRING\$(8," "); PRINT AT(x,y);""; GOTO time.input ENDIF time.inp\$=hour\$+":"+minute\$+":"+second\$ ON ERROR GOSUB program_error ! <<< change if necessary >>> RETURN > PROCEDURE time_input_error ' *** Catch unexpected error ok!=FALSE ON ERROR GOSUB time_input_error RESUME NEXT RETURN ' ********* '