home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol074 / diary.bas < prev    next >
BASIC Source File  |  1984-04-29  |  8KB  |  224 lines

  1. REM    Adapated from September 1981 KILOBAUD/Microcomputing Magazine
  2. REM    by Don Weir, 12/Jan/82
  3. REM
  4. REM    Use CBASIC compiler
  5.  
  6.         CL$=CHR$(12):PRINT CL$
  7.         CODE$="NSCQ"
  8.         BLANK$="                             "
  9.         DASH$="                             "
  10.         REC.SIZE%=110
  11.                 DIM DAY$(7),MONTH$(12),FIRST%(12),DAYS%(12)
  12.                 DIM LINE.1$(8),LINE.2$(8),LINE.3$(8),WK.DY$(8)
  13.         FIRST%(1)=1:FIRST%(2)=32:FIRST%(3)=60:FIRST%(4)=91
  14.        FIRST%(5)=121:FIRST%(6)=152:FIRST%(7)=182:FIRST%(8)=213
  15.     FIRST%(9)=244:FIRST%(10)=274:FIRST%(11)=305:FIRST%(12)=335
  16.         DAYS%(1)=31:DAYS%(2)=28:DAYS%(3)=31:DAYS%(4)=30
  17.         DAYS%(5)=31:DAYS%(6)=30:DAYS%(7)=31:DAYS%(8)=31
  18.         DAYS%(9)=30:DAYS%(10)=31:DAYS%(11)=30:DAYS%(12)=31
  19.        DAY$(1)="Mon":DAY$(2)="Tue":DAY$(3)="Wed":DAY$(4)="Thu"
  20.        DAY$(5)="Fri":DAY$(6)="Sat":DAY$(7)="Sun"
  21.         MONTH$(1)="Jan":MONTH$(2)="Feb":MONTH$(3)="Mar"
  22.         MONTH$(4)="Apl":MONTH$(5)="May":MONTH$(6)="Jun"
  23.         MONTH$(7)="Jul":MONTH$(8)="Aug":MONTH$(9)="Sep"
  24.         MONTH$(10)="Oct":MONTH$(11)="NOv":MONTH$(12)="Dec"
  25. 5       PRINT CL$:PRINT TAB(52);"Adapted from"
  26.         PRINT TAB(52);"KILOBAUD"
  27.         PRINT TAB(52);"Sept. 1981."
  28.                 FOR I%=1 TO 5:PRINT:NEXT I%
  29.         INPUT "Year (i.e., 1981)";YEAR$
  30.         PRINT "Is ";YEAR$;" correct "
  31.         INPUT LINE Q$
  32.         IF LEFT$(Q$,1)="N" THEN 5
  33.         YEAR=VAL(YEAR$)
  34.         A=YEAR/4:B=INT(A):C=A-B
  35.         IF C<>0 THEN 10
  36.         DAYS%(2)=29
  37.         FOR X%=3 TO 12
  38.                 FIRST%(X%)=FIRST%(X%)+1
  39.         NEXT X%
  40. 10      GOSUB 20
  41.         ON T% GOSUB 100,200,300,400
  42.         GOTO 10
  43. 20      PRINT CL$
  44.         PRINT
  45.         IF ERSW1% THEN ERSW1%=0:PRINT TAB(10);"Year not found.":PRINT
  46.         IF ERSW2% THEN ERSW2%=0:PRINT TAB(10);YEAR$;" already exists";:PRINT
  47.         PRINT TAB(24);"CALENDAR"
  48.         PRINT TAB(24);"--------":PRINT:PRINT
  49.         PRINT
  50.         PRINT TAB(10);"N = Set up New Year":PRINT
  51.         PRINT TAB(10);"Y = Change Year":PRINT
  52.         PRINT TAB(10);"S = See":PRINT
  53.         PRINT TAB(10);"C = Change Data":PRINT
  54.         PRINT TAB(10);"Q = Quit":PRINT
  55.         INPUT "Task ";T$
  56.         T$=LEFT$(T$,1)
  57.         IF T$="Y" THEN 5
  58.         FOR T%=1 TO 5
  59.                 IF T$=MID$(CODE$,T%,1) THEN RETURN
  60.         NEXT T%
  61.         GOTO 10
  62. 100     PRINT CL$
  63.         PRINT:PRINT YEAR$:PRINT
  64.         INPUT "Jan 1 day number (Monday=1) ";LINE DAY.NUM$
  65.         IF DAY.NUM$="" THEN RETURN
  66.         DAY.NUM%=VAL(DAY.NUM$)
  67.         IF DAY.NUM%<1 OR DAY.NUM%>7 THEN 100
  68.         PRINT:PRINT "Writing...";
  69.         READ%=0
  70.                         GOSUB 1000
  71.                         IF OLD.FILE% THEN ERSW2%=1:GOTO 110
  72.                      LINE.1$=DASH$:LINE.2$=DASH$:LINE.3$=DASH$
  73.                 FOR X%=1 TO FIRST%(12)+DAYS%(12)
  74.                         REC.NUM%=X%
  75.                         DAY$=DAY$(DAY.NUM%)
  76.                         GOSUB 1200
  77.                         DAY.NUM%=DAY.NUM%+1
  78.                         IF DAY.NUM%>7 THEN DAY.NUM%=1
  79.                         PRINT ".";
  80.                 NEXT X%
  81. 110     PRINT "":CLOSE 1:RETURN
  82.  
  83. 200     PRINT CL$:PRINT:PRINT
  84.         INPUT "Starting date (mm,dd) ";NUM%,DATE%
  85.         IF NUM%<1 OR NUM%>12 THEN 200
  86.         IF DATE%<1 OR DATE%>DAYS%(NUM%) THEN 200
  87.         START%=(FIRST%(NUM%)-1)+DATE%
  88.         READ%=1:NEW%=0
  89.         GOSUB 1000
  90.         IF OLD.FILE%=0 THEN ERSW1%=1:RETURN
  91. 205             FOR X%=1 TO 7
  92.                         REC.NUM%=START%
  93.                         GOSUB 1100
  94.                         DATE$=STR$(DATE%)
  95.         IF NEW%=0 THEN WK.DY$(X%)=DAY$+" "+DATE$
  96.         IF NEW% THEN NEW%=0:WK.DY$(X%)=DAY$+" "+DATE$+" "+"*"
  97.                 LINE.1$(X%)=LINE.1$
  98.                 LINE.2$(X%)=LINE.2$
  99.                 LINE.3$(X%)=LINE.3$
  100.                 DATE%=DATE%+1
  101.                 START%=START%+1
  102.         IF DATE%>DAYS%(NUM%) THEN DATE%=1:NUM%=NUM%+1:NEW%=1
  103.         IF START%>FIRST%(12)+30 THEN START%=1:NUM%=1
  104.                 NEXT X%
  105.         PRINT CL$
  106. 210     IF TASK$="P" THEN PRINT:PRINT:PRINT:PRINT TAB(5);MONTH$(NUM%);" ";YEAR$:PRINT:GOTO 215
  107.         PRINT TAB(25);MONTH$(NUM%);" ";YEAR$:PRINT
  108. 215     FOR X%=1 TO 7 STEP 2
  109.                 PRINT WK.DY$(X%);TAB(40);WK.DY$(X%+1)
  110.                 PRINT LINE.1$(X%);TAB(40);LINE.1$(X%+1)
  111.                 PRINT LINE.2$(X%);TAB(40);LINE.2$(X%+1)
  112.                 PRINT LINE.3$(X%);TAB(40);LINE.3$(X%+1)
  113.         REM     PRINT
  114.         NEXT X%
  115.         IF TASK$="P" THEN CONSOLE
  116.         PRINT TAB(5);"P = Print  Return-next  Q = Quit"
  117.         PRINT TAB(5);"Task ";
  118.         INPUT LINE TASK$:TASK$=LEFT$(TASK$,1)
  119.         IF TASK$="Q" THEN 220
  120.         IF TASK$="P" THEN LPRINTER WIDTH 80:GOTO 210
  121.                 GOTO 205
  122. 220     CLOSE 1:READ%=0
  123.         RETURN
  124. 300     READ%=1
  125.         GOSUB 1000
  126.         IF OLD.FILE%=0 THEN ERSW1%=0:RETURN
  127. 310     PRINT CL$
  128.         INPUT "Date (mm,dd) ";NUM%,DATE%
  129.         IF NUM%<1 OR NUM%>12 THEN 310
  130.         IF DATE%<1 OR DATE%>DAYS%(NUM%) THEN 310
  131. 320     REC.NUM%=(FIRST%(NUM%)-1)+DATE%
  132.                         GOSUB 1100
  133. 330     PRINT CL$
  134.         PRINT:PRINT:PRINT
  135.         PRINT TAB(20);MONTH$(NUM%);" ";YEAR$:PRINT
  136.         PRINT TAB(20);DAY$;DATE%
  137.         PRINT TAB(20);LINE.1$
  138.         PRINT TAB(20);LINE.2$
  139.         PRINT TAB(20);LINE.3$
  140.         PRINT
  141.     PRINT TAB(2);"(B-Blank  W-Write  S-Switch  N-New date)";
  142.     PRINT "  RETURN-next  Q-Quit)"
  143.         PRINT TAB(5);"Task";
  144.         INPUT LINE TASK$:TASK$=LEFT$(TASK$,1)
  145.         IF TASK$="N" OR TASK$="" THEN 350
  146.         IF TASK$="Q" THEN 360
  147.         IF TASK$="B" THEN GOSUB 1300
  148.         IF TASK$="W" THEN GOSUB 1400
  149.         IF TASK$="S" THEN 340
  150.                 GOTO 330
  151. 340 INPUT "Switch date (mm,dd) ";SM%,SD%
  152.         IF SM%<1 OR SM%>12 THEN 340
  153.         IF SD%<1 OR SD%>DAYS%(SM%) THEN 340
  154.         REC.1%=REC.NUM%
  155.         DAY.1$=DAY$
  156.         HOLD.1$=LINE.1$:HOLD.2$=LINE.2$:HOLD.3$=LINE.3$
  157.         REC.NUM%=(FIRST%(SM%)-1)+SD%
  158.                 GOSUB 1100
  159.                 DAY.2$=DAY$
  160.                 REC.2%=REC.NUM%
  161.                 DAY$=DAY.1$
  162.                 REC.NUM%=REC.1%
  163.                 GOSUB 1200
  164.         DAY$=DAY.2$
  165.         LINE.1$=HOLD.1$
  166.         LINE.2$=HOLD.2$
  167.         LINE.3$=HOLD.3$
  168.                 REC.NUM%=REC.2%
  169.                 GOSUB 1200
  170.                 REC.NUM%=REC.1%
  171.                 GOSUB 1100
  172.                 GOTO 330
  173. 350     GOSUB 1200
  174.         IF TASK$="N" THEN 310
  175.         DATE%=DATE%+1
  176.         IF DATE%>DAYS%(NUM%) THEN DATE%=1:NUM%=NUM%+1
  177.         IF NUM%>12 THEN NUM%=1
  178.         GOTO 320
  179. 360     GOSUB 1200
  180.                 CLOSE 1:READ%=0
  181.                 RETURN
  182. 400     PRINT CL$
  183.                         STOP
  184. 1000    OLD.FILE%=0
  185.         IF END #1 THEN 1010
  186.         FILE$=YEAR$+".DAT"
  187.         OPEN FILE$ RECL REC.SIZE% AS 1
  188.         OLD.FILE%=1
  189.         GOTO 1020
  190. 1010    IF READ% THEN 1020
  191.         CREATE FILE$ RECL REC.SIZE% AS 1
  192. 1020    RETURN
  193.  
  194. 1100    END.FILE%=0
  195.         IF END # 1 THEN 1110
  196.         READ # 1,REC.NUM%;DAY$,LINE.1$,LINE.2$,LINE.3$
  197.                 RETURN
  198. 1110    END.FILE%=1
  199.                 RETURN
  200. 1200    PRINT # 1,REC.NUM%;DAY$,LINE.1$,LINE.2$,LINE.3$
  201.                 RETURN
  202. 1300    PRINT TAB(5);"Line 1, 2, 3  or all";
  203.         INPUT LINE LN.NUM$
  204.         IF LN.NUM$="" THEN 1310
  205.         LN.NUM$=LEFT$(LN.NUM$,1)
  206.         IF LN.NUM$="A" THEN LINE.1$=DASH$:LINE.2$=DASH$:LINE.3$=DASH$
  207.         IF LN.NUM$="1" THEN LINE.1$=DASH$
  208.         IF LN.NUM$="2" THEN LINE.2$=DASH$
  209.         IF LN.NUM$="3" THEN LINE.3$=DASH$
  210. 1310            RETURN
  211. 1400 PRINT "Line #1 ";"------------------------------*"
  212.      INPUT "       ";LINE LN$
  213.         IF LN$="" THEN 1410
  214.         LINE.1$=LEFT$(LN$+BLANK$,30)
  215. 1410 PRINT "Line #2 ";"------------------------------*"
  216.      INPUT "       ";LINE LN$
  217.         IF LN$="" THEN 1420
  218.         LINE.2$=LEFT$(LN$+BLANK$,30)
  219. 1420 PRINT "Line #3 ";"------------------------------*"
  220.      INPUT "       ";LINE LN$
  221.         IF LN$="" THEN 1430
  222.         LINE.3$=LEFT$(LN$+BLANK$,30)
  223. 1430 RETURN
  224.