BBS: Inland Empire Archive Date: 02-17-93 (16:05) Number: 255 From: MICHEL BERTLER Refer#: NONE To: RAYMOND KEITH Recvd: NO Subj: DAYS.BAS 1/2 Conf: (2) Quik_Bas
Hello Raymond!
In a message of <11 Feb 93>, Raymond Keith (1:105/224) writes:
RK> Rob heres an ugly piece of code. It seems to get the job done but just
RK> looks sloppy to me.
RK> '***********************************************************************
RK> * '* This routine checks for data entry errors made when a user inputs
RK> * '* a date. Proper format ##/##/## is checked as well as proper values,
RK> * '* 30 day months, Feb with regards to leap years, range of valid
RK> years. * '* This routine is good for years 1904 to 1999.
RK> * '*********************************************************************
It has been a while since the following was initially posted here but
maybe it is worth reposting it! All credit go to mr.Bill Campbell the
author. This will be my first try with MSGSPLIT! Thanks Victor & Scott!
Part one of DAYS.BAS...
________O_/________________________| SNIP |______________________\_O_______
O \ | HERE | / O
begin:
usedate$ = DATE$
CLS
LOCATE 25, 27: COLOR 9, 0: PRINT "A Quicky by Bill Campbell";
LOCATE 7, 15: COLOR 15, 0
PRINT "(I)nput your own date or (U)se today's date"
x$ = ""
DO: x$ = INKEY$: IF x$ = "I" OR x$ = "i" OR x$ = "U" OR x$ = "u" THEN EXIT DO
LOOP
LOCATE 9, 32: COLOR 15, 0
IF x$ = "i" OR x$ = "I" THEN
PRINT "DAY - MONTH - YEAR"
LOCATE 10, 32: PRINT "## ## ####"
ROW = 10: mydate$ = "": column = 32: flag = 0: SETLENGTH = 8
LOCATE 9, 32: COLOR 12, 0
BuildDate:
select$ = ""
DO WHILE select$ <> CHR$(13) AND flag < SETLENGTH
select$ = INKEY$
IF flag = 0 THEN
column = 32
ELSEIF flag = 1 THEN
column = 33
ELSEIF flag = 2 THEN
column = 39
ELSEIF flag = 3 THEN
column = 40
ELSEIF flag > 3 THEN
column = flag + 42
END IF
IF flag = 0 AND select$ > "3" THEN GOTO BuildDate
IF flag = 2 AND select$ > "1" THEN GOTO BuildDate
IF flag = 4 AND (select$ > "2" OR select$ < "1") THEN GOTO BuildDate
IF select$ > CHR$(47) AND select$ < CHR$(58) THEN GOTO GotChar
GOTO BuildDate
GotChar:
LOCATE ROW, column: PRINT select$
flag = flag + 1: mydate$ = mydate$ + select$
IF flag = 2 OR flag = 4 THEN mydate$ = mydate$ + "-"
LOOP
dummy$ = LEFT$(mydate$, 2): MID$(mydate$, 1, 2) = MID$(mydate$, 4, 2)
MID$(mydate$, 4, 2) = dummy$: usedate$ = mydate$
PRINT
ELSE
PRINT "DAY - MONTH - YEAR": COLOR 12, 0
LOCATE 10, 32
PRINT MID$(DATE$, 4, 2) + " " + LEFT$(DATE$, 2) + " " +_
RIGHT$(DATE$, 4)
PRINT
END IF
COLOR 15, 0
DIM days$(7)
days$(1) = "Sunday": days$(2) = "Monday": days$(3) = "Tuesday": _
days$(4) = "Wednesday": days$(5) = "Thursday": days$(6) = "Friday": _
days$(7) = "Saturday"
DIM month$(12, 2)
month$(1, 1) = "January": month$(1, 2) = "31"
month$(2, 1) = "February": month$(2, 2) = "28"
month$(3, 1) = "March": month$(3, 2) = "31"
month$(4, 1) = "April": month$(4, 2) = "30"
month$(5, 1) = "May": month$(5, 2) = "31"
month$(6, 1) = "June": month$(6, 2) = "30"
month$(7, 1) = "July": month$(7, 2) = "31"
month$(8, 1) = "August": month$(8, 2) = "31"
Continued on next message...
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