' *** DATE_INP.LST *** 2nd GFA-Manual, page 3-10 > PROCEDURE date_input(VAR date.inp\$) ' ' *** Enter date at current cursor-position ' *** Procedure accepts various formats: 1-6-'88 02-11-88 3.6.88 ' *** 2/1/88 12 June 1988 9 aug 88 ' *** If two digits are used for the year, this is converted to '19..' ' *** After checking for errors, the date is returned as "dd.mm.yyyy" ' *** Procedure uses ERROR for catching unexpected errors ' ' *** Procedure: Program_error Date_input_error ' LOCAL x,y,date.input\$,ok!,day\$,day,month.input\$,month\$ LOCAL n,month!,month,year\$,year x=CRSCOL y=CRSLIN ON ERROR GOSUB date_input_error ' date.input: ' *** Input of date ok!=TRUE FORM INPUT 18,date.input\$ ' *** Day day.len=VAL?(date.input\$) IF day.len>2 ! in case of format 2.3.88 IF INSTR(date.input\$,".")=2 day.len=1 ELSE IF INSTR(date.input\$,".")=3 day.len=2 ELSE ok!=FALSE ENDIF ENDIF ENDIF day\$=LEFT\$(date.input\$,day.len) WHILE LEFT\$(day\$,1)="0" ! remove zeroes day\$=RIGHT\$(day\$,LEN(day\$)-1) WEND day=VAL(day\$) IF day>31 OR day<1 ok!=FALSE ENDIF ' *** Month month.input\$=RIGHT\$(date.input\$,LEN(date.input\$)-(day.len+1)) month.len=VAL?(month.input\$) IF month.len=0 ! month entered as (abbreviated) name month\$=LEFT\$(month.input\$,3) month\$=UPPER\$(month\$) month.data: DATA JAN,1,FEB,2,MAR,3,APR,4,MAY,5,JUN,6,JUL,7 DATA AUG,8,SEP,9,OCT,10,NOV,11,DEC,12 DIM date.input.month\$(12),date.input.month(12) RESTORE month.data FOR n=1 TO 12 READ date.input.month\$(n),date.input.month(n) NEXT n FOR n=1 TO 12 IF date.input.month\$(n)=month\$ month!=TRUE month=date.input.month(n) ENDIF NEXT n ERASE date.input.month\$() ERASE date.input.month() IF NOT month! ok!=FALSE ENDIF ELSE month=VAL(month.input\$) ! month entered as number ENDIF IF month>12 OR month<1 ok!=FALSE ENDIF month\$=STR\$(month) IF (month=4 OR month=6 OR month=9 OR month=11) AND day>30 ok!=FALSE ENDIF IF (month=1 OR month=3 OR month=5 OR month=7 OR month=8 OR month=10 OR month=12) AND day>31 ok!=FALSE ENDIF ' *** Year year\$=RIGHT\$(date.input\$,4) IF VAL?(year\$)<>4 OR INSTR(year\$,".") year\$=RIGHT\$(date.input\$,3) IF LEFT\$(year\$)=" " year\$=RIGHT\$(year\$,2) ENDIF IF VAL?(year\$)<>3 OR INSTR(year\$,".") OR VAL(year\$)<0 year\$=RIGHT\$(date.input\$,2) IF VAL?(year\$)<>2 OR INSTR(year\$,".") ok!=FALSE ENDIF year\$="19"+year\$ ! year YY converted to 19YY ENDIF ENDIF WHILE LEFT\$(year\$,1)="0" ! remove zeroes year\$=RIGHT\$(year\$,LEN(year\$)-1) WEND year=VAL(year\$) IF month=2 ! check for leap year in February IF day>28 IF (year MOD 400=0) AND day<>29 ok!=FALSE ELSE IF year MOD 100=0 AND (year MOD 400<>0) ok!=FALSE ELSE IF (year MOD 4=0) AND day<>29 ok!=FALSE ELSE IF (year MOD 4<>0) ok!=FALSE ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ' *** Date IF NOT ok! PRINT CHR\$(7); PRINT AT(x,y);STRING\$(LEN(date.input\$)," "); PRINT AT(x,y);"WRONG FORMAT !!"; PAUSE 50 PRINT AT(x,y);STRING\$(15," "); PRINT AT(x,y);""; GOTO date.input ENDIF date.inp\$=day\$+"."+month\$+"."+year\$ ON ERROR GOSUB program_error ! <<< change if necessary >>> RETURN > PROCEDURE date_input_error ' *** Catch unexpected error ok!=FALSE ON ERROR GOSUB date_input_error RESUME NEXT RETURN ' ********* '