40. Date input routine ~~~~~~~~~~~~~~~~~~ This is a reasonably 'intelligent' Procedure for entering the date in a program. It checks for sensible days, months and years, (1984 to 1999), takes account of the different number of days in each month, and allows for Leap Years. The original was written by a chap called Tim Davies, but I've altered it a bit! You can enter the date in many forms, eg. 27.08.84 or 27-8-84 or 27/8/1984 or 27 8 84 or 27,08,84 and so on. The result is a string, date$, which holds the date in the form 27-AUG-1984, and also three integer variables, d%, m% and y%, which represent the day, month and year. If you do not want the string date$, then change line 1070 to ENDPROC. If you do not want to use the integer variables, then add them to the list of LOCAL variables in line 1000. If you enter an invalid date, a beep will sound, and you will be invited to try again. Note the use of INPUTLINE rather than INPUT, in order to permit commas in the date. 10 PROCdate:PRINT'"Todays Date is "date$'d%,m%,y%' 20 GOTO10 1000 DEFPROCdate:LOCALmx%,I%,d$,m$,y$:*FX21,0 1010 PRINT:REPEAT:REPEATVDU127:UNTILPOS=0:INPUTLINE"Please submit date as DD.MM.YY "date$ 1020 d$=LEFT$(date$,2):IFASC(RIGHT$(d$,1))<48THENm$=MID$(date$,3,2) ELSEm$=MID$(date$,4,2) 1030 y$=RIGHT$(date$,2):d%=VAL(d$):m%=VAL(m$):y%=VAL(y$)+1900 1040 RESTORE1080:FORI%=1TOm%MOD13:READm$,mx%:NEXT 1050 IFy%MOD4=0ANDm%=2THENmx%=29 1060 VDU7:UNTILd%>0ANDd%<=mx%ANDm%>0ANDm%<13ANDy%>1983:*FX21,7 1070 date$=STR$(d%)+"-"+m$+"-"+STR$(y%):ENDPROC 1080 DATA JAN,31,FEB,28,MAR,31,APR,30,MAY,31,JUN,30,JUL,31, AUG,31,SEP,30,OCT,31,NOV,30,DEC,31