BBS: Inland Empire Archive Date: 02-17-93 (16:10) Number: 256 From: MICHEL BERTLER Refer#: NONE To: RAYMOND KEITH Recvd: NO Subj: DAYS.BAS 2/2 Conf: (2) Quik_Bas
Part 2 of DAYS.BAS - continued from last message... month$(9, 1) = "September": month$(9, 2) = "30" month$(10, 1) = "October": month$(10, 2) = "31" month$(11, 1) = "November": month$(11, 2) = "30" month$(12, 1) = "December": month$(12, 2) = "31" DIM DayYearStarted$(14) ' 1 = sunday and 7 = saturday as per the array days$ FOR startday = 1 TO 7 DayYearStarted$(startday) = days$(startday) DayYearStarted$(startday + 7) = days$(startday) NEXT startday '1901 started on yeartype 3 and the repeating sequence for yeartypes is :_ ' 3 45 13 1 2 3 11 6 7 1 9 4 5 6 14 2 3 4 12 7 1 2 10 5 6 7 8 DIM yearsequence(28) yearsequence(1) = 3 ' if year = 1901 then use yearsequence(1) yearsequence(2) = 4 ' if year = 1902 then use yearsequence(2) yearsequence(3) = 5 ' if year = 1903 then use yearsequence(3) yearsequence(4) = 13 yearsequence(5) = 1: yearsequence(6) = 2: yearsequence(7) = 3 yearsequence(8) = 11: yearsequence(9) = 6: yearsequence(10) = 7 yearsequence(11) = 1: yearsequence(12) = 9: yearsequence(13) = 4 yearsequence(14) = 5: yearsequence(15) = 6: yearsequence(16) = 14 yearsequence(17) = 2: yearsequence(18) = 3: yearsequence(19) = 4 yearsequence(20) = 12: yearsequence(21) = 7: yearsequence(22) = 1 yearsequence(23) = 2: yearsequence(24) = 10: yearsequence(25) = 5 yearsequence(26) = 6: yearsequence(27) = 7: yearsequence(28) = 8 year = VAL(RIGHT$(usedate$, 4)) ' determine yeartype IF year MOD 4 = 0 THEN leap = -1 year = year - 1900: WHILE year > 28: year = year - 28: WEND: whichyeartype_ = year MOD 29 PointerToDayYearStarted = yearsequence(whichyeartype) startdayvalue = PointerToDayYearStarted IF startdayvalue > 7 THEN startdayvalue = startdayvalue - 7: startday$ =_ DayYearStarted$(PointerToDayYearStarted) ' compute number of days this year numofcompletemonths = VAL(MID$(usedate$, 1, 2)) - 1 FOR countmonths = 1 TO numofcompletemonths numofdays = numofdays + VAL(month$(countmonths, 2)): NEXT countmonths numofdays = numofdays + VAL(MID$(usedate$, 4, 2)) IF leap THEN IF VAL(MID$(usedate$, 1, 2)) > 1 THEN IF VAL(MID$(usedate$, 1, 2)) > 2 OR VAL(MID$(usedate$, 4, 2)) > 28 THEN numofdays = numofdays + 1 END IF END IF END IF whatday = (numofdays MOD 7) - 1 whatday = whatday + startdayvalue IF whatday > 7 THEN whatday = whatday - 7 thisday$ = days$(whatday) thismonth$ = month$(VAL(MID$(usedate$, 1, 2)), 1) calendardate$ = MID$(usedate$, 4, 2) thisyear$ = RIGHT$(usedate$, 4) SP$ = SPACE$(22) PRINT SP$; "Number of days to date is "; numofdays IF leap AND numofdays > (31 + 28) THEN COLOR 7, 0: PRINT SP$; " leap"+_ " year counted": COLOR 15, 0 PRINT SP$; "This "; : IF leap THEN PRINT "LEAP "; PRINT "year started on a "; startday$ PRINT SP$; IF x$ = "u" OR x$ = "U" THEN PRINT "Today is "; thisday$ PRINT SP$; "Today's date is "; usedate$ ELSE PRINT "Chosen date is a "; thisday$ PRINT SP$; "Chosen date is "; usedate$ END IF PRINT SP$; "Which translates to:": COLOR 14, 0 PRINT SP$; thisday$ + " " + thismonth$ + " " + calendardate$ + ", " + thisyear$ PRINT : COLOR 15, 0 PRINT SP$; "Repeat ? (Y)es or (N)o" x$ = "" DO: x$ = INKEY$: IF x$ = "Y" OR x$ = "y" OR x$ = "N" OR x$ = "n" THEN EXIT DO LOOP IF x$ = "Y" OR x$ = "y" THEN CLEAR : GOTO begin LOCATE 24, 27: COLOR 25, 0: PRINT "A Quicky by Bill Campbell": LOCATE 25, 79 END ________O_/________________________| SNIP |______________________\_O_______ O \ | HERE | / O Line wrapping and message splitted accomplished by MsgSplit 2.00, a Victor Yiu and Scott Wunsch creation. Michel --- GoldED * Origin: Blainville, Quebec (1:242/130)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET