home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug165.arc
/
RECONDAT.BAS
< prev
next >
Wrap
BASIC Source File
|
1979-12-31
|
3KB
|
84 lines
5 REM Recondat.bas - Prompt V1 No7 April 91 p19
8 PRINT CHR$(26) ' Clear the screen
10 INPUT "Enter date as day,month,year. <e.g. 31dec1991 > ";A$
20 IF LEN(A$) < 9 THEN A$="0"+A$
30 C$=LEFT$(A$,2)
40 B$=MID$(A$,3,3)
50 Y$=RIGHT$(A$,4)
60 IF VAL(Y$)=0 THEN PRINT "Year must be 4 digits long, e.g. 0900.":END
70 GOSUB 470: IF B$="0" THEN PRINT"Not a month error.":END
80 IF C$>"31" THEN PRINT "Too many days error.":END
90 D$=B$+C$+Y$
100 PRINT D$ " <- date as an 8 digit string."
110 D1$=LEFT$(D$,3):D2$=MID$(D$,4,3):D3$=RIGHT$(D$,2):D3$="0"+D3$
120 E1$=RIGHT$(D1$,1):E2$=LEFT$(D2$,1)
130 MID$(D1$,3)=E2$:MID$(D2$,1)=E1$
140 IF E1$="3" THEN MID$(D2$,1)="2":MID$(D3$,1)="1"
150 PRINT D1$ D2$ D3$" <- 9 digit string representing the date."
160 DA$=CHR$(VAL(D1$)+33)
170 DB$=CHR$(VAL(D2$)+33)
180 DC$=CHR$(VAL(D3$)+33)
190 PRINT "->"DA$ DB$ DC$"<- 3 digit compressed date string."
200 D$=DA$+DB$+DC$
210 OPEN "r",#1,"CM.COD",3
220 FIELD#1,3 AS DD$
230 LSET DD$=D$
240 PUT #1,1
250 GET #1,1
260 PRINT DD$ " <- read from file."
270 R1$=RIGHT$(STR$(ASC(DA$)-33),3)
280 IF LEFT$(R1$,1)=" " THEN MID$(R1$,1)="0"
290 IF LEN(R1$)=2 THEN R1$="0"+R1$
300 R2$=RIGHT$(STR$(ASC(DB$)-33),3)
310 IF LEFT$(R2$,1)=" " THEN MID$(R2$,1)="0"
320 IF LEN(R2$)=2 THEN R2$="0"+R2$
330 R3$=RIGHT$(STR$(ASC(DC$)-33),3)
340 IF LEFT$(R3$,1)=" " THEN MID$(R3$,1)="0"
350 E1$=RIGHT$(R1$,1):E2$=LEFT$(R2$,1):E3$=LEFT$(R3$,1)
360 MID$(R1$,3)=E2$:MID$(R2$,1)=E1$
370 IF E3$="1" THEN MID$(R1$,3)="3"
380 R3$=RIGHT$(R3$,2)
390 R$=R1$+R2$+R3$
400 PRINT R$ " <- 8 digit string representing the date."
410 S1$=LEFT$(R$,2):S2$=MID$(R$,3,2):S3$=RIGHT$(R$,4)
420 GOSUB 600:GOSUB 730
430 IF LEFT$(S2$,1)="0" THEN S2$=RIGHT$(S2$,4)
440 IF LEFT$(S3$,1)="0" THEN S3$=RIGHT$(S3$,LEN(S3$)-1):GOTO 440
450 PRINT S2$ S1$ S3$ " <- expanded 3 digit date string."
460 END
470 IF B$="jan" THEN B$="01":RETURN
480 IF B$="feb" THEN B$="02":RETURN
490 IF B$="mar" THEN B$="03":RETURN
500 IF B$="apr" THEN B$="04":RETURN
510 IF B$="may" THEN B$="05":RETURN
520 IF B$="jun" THEN B$="06":RETURN
530 IF B$="jul" THEN B$="07":RETURN
540 IF B$="aug" THEN B$="08":RETURN
550 IF B$="sep" THEN B$="09":RETURN
560 IF B$="oct" THEN B$="10":RETURN
570 IF B$="nov" THEN B$="11":RETURN
580 IF B$="dec" THEN B$="12":RETURN
590 B$="0":RETURN
600 IF S1$="01" THEN S1$="January ":RETURN
610 IF S1$="02" THEN S1$="February ":RETURN
620 IF S1$="03" THEN S1$="March ":RETURN
630 IF S1$="04" THEN S1$="April ":RETURN
640 IF S1$="05" THEN S1$="May ":RETURN
650 IF S1$="06" THEN S1$="June ":RETURN
660 IF S1$="07" THEN S1$="July ":RETURN
670 IF S1$="08" THEN S1$="August ":RETURN
680 IF S1$="09" THEN S1$="September ":RETURN
690 IF S1$="10" THEN S1$="October ":RETURN
700 IF S1$="11" THEN S1$="November ":RETURN
710 IF S1$="12" THEN S1$="December ":RETURN
720 PRINT "Error.":END
730 IF S2$="11" THEN S2$=S2$+"th ":RETURN
740 IF S2$="12" THEN S2$=S2$+"th ":RETURN
750 IF S2$="13" THEN S2$=S2$+"th ":RETURN
760 IF RIGHT$(S2$,1)="1" THEN S2$=S2$+"st ":RETURN
770 IF RIGHT$(S2$,1)="2" THEN S2$=S2$+"nd ":RETURN
780 IF RIGHT$(S2$,1)="3" THEN S2$=S2$+"rd ":RETURN ' Do all others.
790 S2$=S2$+"th ":RETURN
"2" THEN S2$=S2$+"nd ":RETURN
780 IF RIGHT$(S2$,1)="3" THEN S2$=S2$+"rd ":RETURN ' Do all others.
790 S2$=S2$+"th ":R