DELETE BIO; REDEFINE PROCEDURE BIO DECLARE P USAGE REAL EDIT_STRING S9.999. DECLARE S USAGE REAL EDIT_STRING S9.999. DECLARE I USAGE REAL EDIT_STRING S9.999. DECLARE N PIC S9999999V9 EDIT_STRING Z,ZZZ,ZZZ.9. DECLARE D1 USAGE DATE. DECLARE D2 USAGE DATE. DECLARE D3 USAGE DATE. D1 = *."your birthday" D2 = "TODAY" REPEAT 21 BEGIN N = D2 - D1 ! Number of days interval ! ! Convert number of days to radians by multiplying by 2 PI and ! dividing by the number of days in the cycle ! P = FN$SIN(N * 0.273182) S = FN$SIN(N * 0.2243995) I = FN$SIN(N * 0.1903996) ! PRINT D2, N, P, S, I ! D2 = D2 + 0.5 ! go to next half day END END_PROCEDURE DELETE BIO2; REDEFINE PROCEDURE BIO2 DECLARE P USAGE REAL EDIT_STRING S9.999. DECLARE S USAGE REAL EDIT_STRING S9.999. DECLARE I USAGE REAL EDIT_STRING S9.999. DECLARE N PIC S9999999V9 EDIT_STRING Z,ZZZ,ZZZ.9. DECLARE D1 USAGE DATE. DECLARE D2 USAGE DATE. DECLARE D3 USAGE DATE. DECLARE Q1 USAGE QUAD. DECLARE Q2 USAGE QUAD. DECLARE Q3 USAGE QUAD. D1 = *."your birthday" D2 = "TODAY" Q1 = D1 ! have to convert days to quads Q2 = D2 Q3 = Q2 - Q1 ! Number of days interval REPEAT 21 BEGIN N = Q3 / 864000000000 ! convert clunks to days ! ! Convert number of days to radians by multiplying by 2 PI and ! dividing by the number of days in the cycle ! P = FN$SIN(N * 0.273182) S = FN$SIN(N * 0.2243995) I = FN$SIN(N * 0.1903996) ! D3 = Q1 + Q3 ! convert clunks back to date ! PRINT N, P, S, I, D3, FN$TIME(D3) ! Q3 = Q3 + 432000000000 ! go to next half day (in clunks) END END_PROCEDURE DELETE BIO_DAT; REDEFINE DOMAIN BIO_DAT USING BIO_REC ON BIO.SEQ; DELETE BIO_REC; REDEFINE RECORD BIO_REC USING OPTIMIZE 01 BIO_REC. 05 DAY USAGE DATE. 05 NUMBERS. 10 P USAGE REAL EDIT_STRING S9.999. 10 S USAGE REAL EDIT_STRING S9.999. 10 I USAGE REAL EDIT_STRING S9.999. 05 CHARACTERS. 10 PRINT_STRING PIC X(51). ! once as a string 10 PRINT_ARRAY REDEFINES PRINT_STRING. ! redefine as an array 20 PRINT_CHAR OCCURS 51 TIMES. ! of sincle characters 30 CHAR PIC X. ; DELETE BIO_REPORT; REDEFINE PROCEDURE BIO_REPORT ! ! Report biorhythms already generated. ! ! B. Z. Lederman ! READY BIO_DAT ! REPORT BIO_DAT ON *."file name or TT " SET COLUMNS_PAGE = 72 AT TOP OF REPORT PRINT "Biorhythm chart for a birthdate of", SPACE 1, D1 USING W(9)BDD_MMM_YYYY, SKIP 2, COL 29, "(-) (0) (+)" PRINT COL 2, CHOICE ! print date for only one FN$HOUR(DAY) = 0 THEN DAY ! of the two data points ELSE " " END_CHOICE USING WWWBNN/DD, SPACE 2, PRINT_STRING AT BOTTOM OF REPORT PRINT SKIP 2 END_REPORT ! END_PROCEDURE DELETE MAKE_BIO; REDEFINE PROCEDURE MAKE_BIO DEFINE FILE FOR BIO_DAT; READY BIO_DAT WRITE DECLARE P USAGE REAL EDIT_STRING S9.999. DECLARE S USAGE REAL EDIT_STRING S9.999. DECLARE I USAGE REAL EDIT_STRING S9.999. DECLARE N PIC S9999999V9 EDIT_STRING Z,ZZZ,ZZZ.9. DECLARE D1 USAGE DATE. DECLARE D2 USAGE DATE. DECLARE D3 USAGE DATE. DECLARE Q1 USAGE QUAD. DECLARE Q2 USAGE QUAD. DECLARE Q3 USAGE QUAD. D1 = *."your birthday" D2 = "TODAY" Q1 = D1 ! have to convert days to quads Q2 = D2 Q3 = Q2 - Q1 ! Number of days interval REPEAT 28 BEGIN ! store data for 14 days by half day N = Q3 / 864000000000 ! convert clunks to days ! ! Convert number of days to radians by multiplying by 2 PI and ! dividing by the number of days in the cycle ! P = FN$SIN(N * 0.273182) S = FN$SIN(N * 0.2243995) I = FN$SIN(N * 0.1903996) ! D3 = Q1 + Q3 ! convert clunks back to date ! STORE BIO_DAT USING BEGIN DAY = D3 P = P S = S I = I END ! Q3 = Q3 + 432000000000 ! go to next half day (in clunks) END ! PRINT BIO_DAT ! END_PROCEDURE DELETE MAKE_BIO_1; REDEFINE PROCEDURE MAKE_BIO_1 ! ! Calculate biorhythms for a given birthdate starting with "TODAY" and ! going on for 14 days, 2 values per day (midnight and noon), store ! it in a file in "graphic" format, then report it. ! ! This version does it in one pass (hopefully) ! ! B. Z. Lederman ! ! The following is faster than erasing old records, but you have ! to purge old files once in a while. Other alternatives (like ! erasing an indexed file) aren't as fast. ! DEFINE FILE FOR BIO_DAT; ! READY BIO_DAT WRITE ! ! Need some temporary variables ! DECLARE P USAGE REAL EDIT_STRING S9.999. DECLARE S USAGE REAL EDIT_STRING S9.999. DECLARE I USAGE REAL EDIT_STRING S9.999. DECLARE IP USAGE INTEGER. DECLARE IS USAGE INTEGER. DECLARE II USAGE INTEGER. DECLARE J USAGE INTEGER. DECLARE N PIC S9999999V9 EDIT_STRING Z,ZZZ,ZZZ.9. ! DECLARE D1 USAGE DATE. DECLARE D2 USAGE DATE. DECLARE D3 USAGE DATE. DECLARE Q1 USAGE QUAD. DECLARE Q2 USAGE QUAD. DECLARE Q3 USAGE QUAD. ! ! The following is used to format the "graph" ! DECLARE BLANK PIC X(51). BLANK = " : " ! ! Get the subject's birthday, and today's date. ! D1 = *."your birthday" D2 = "TODAY" ! ! The whole trick to calculating half days is to convert dates ! to quad-word integers to do the calculations in "clunks", then ! back to dates for formatting output ! Q1 = D1 ! have to convert days to quads Q2 = D2 Q3 = Q2 - Q1 ! Number of days interval IF Q3 < 0 THEN Q3 = 1 ! any date in the future becomes yesterday !N = Q3 / 864000000000 ! convert clunks to days N = D2 - D1 ! get whole days here ! PRINT SKIP, " You are ", N (-) USING ZZ,ZZ9, " days old." ! REPEAT 28 BEGIN ! store data for 14 days by half day N = Q3 / 864000000000 ! convert clunks to days ! ! Convert number of days to radians by multiplying by 2 PI and ! dividing by the number of days in the cycle (because SINE wants ! it's argument in radians). ! P = FN$SIN(N * 0.273182) S = FN$SIN(N * 0.2243995) I = FN$SIN(N * 0.1903996) ! ! Scale the variables to fit a -25 to +25 graph (51 print positions) ! IP = FN$NINT(P * 25) IS = FN$NINT(S * 25) II = FN$NINT(I * 25) ! D3 = Q1 + Q3 ! convert clunks back to date ! ! store the data ! STORE BIO_DAT USING BEGIN ! into new or empty file DAY = D3 P = P S = S I = I PRINT_STRING = BLANK ! ! Now go back over the data and make the print string into a ! horizontal graph. ! ! Note the use of the re-defined field to treat PRINT_STRING as an array. ! J = -25 FOR PRINT_ARRAY MODIFY USING BEGIN IF IP = J THEN CHAR = "P" IF IS = J THEN CHAR = "S" IF II = J THEN CHAR = "I" J = J + 1 END END ! Q3 = Q3 + 432000000000 ! go to next half day (in clunks) END ! ! Now all that has to be done is to print it out. ! REPORT BIO_DAT ON *."file name or TT " SET COLUMNS_PAGE = 72 AT TOP OF REPORT PRINT "Biorhythm chart for a birthdate of", SPACE 1, D1 USING W(9)BDD_MMM_YYYY, SKIP 2, COL 29, "(-) (0) (+)" PRINT COL 2, CHOICE ! print date for only one FN$HOUR(DAY) = 0 THEN DAY ! of the two data points ELSE " " END_CHOICE USING WWWBNN/DD, SPACE 2, PRINT_STRING AT BOTTOM OF REPORT PRINT SKIP 2 END_REPORT ! END_PROCEDURE DELETE MAKE_BIO_PRINT; REDEFINE PROCEDURE MAKE_BIO_PRINT ! ! Calculate biorhythms for a given birthdate starting with "TODAY" and ! going on for 14 days, 2 values per day (midnight and noon), store ! it in a file in "graphic" format, then report it. ! ! B. Z. Lederman ! ! The following is faster than erasing old records, but you have ! to purge old files once in a while. Other alternatives (like ! erasing an indexed file) aren't as fast. ! DEFINE FILE FOR BIO_DAT; ! READY BIO_DAT WRITE ! ! Need some temporary variables ! DECLARE P USAGE REAL EDIT_STRING S9.999. DECLARE S USAGE REAL EDIT_STRING S9.999. DECLARE I USAGE REAL EDIT_STRING S9.999. DECLARE IP USAGE INTEGER. DECLARE IS USAGE INTEGER. DECLARE II USAGE INTEGER. DECLARE J USAGE INTEGER. DECLARE N PIC S9999999V9 EDIT_STRING Z,ZZZ,ZZZ.9. ! DECLARE D1 USAGE DATE. DECLARE D2 USAGE DATE. DECLARE D3 USAGE DATE. DECLARE Q1 USAGE QUAD. DECLARE Q2 USAGE QUAD. DECLARE Q3 USAGE QUAD. ! ! The following is used to format the "graph" ! DECLARE BLANK PIC X(51). BLANK = " : " ! ! Get the subject's birthday, and today's date. ! D1 = *."your birthday" D2 = "TODAY" ! ! The whole trick to calculating half days is to convert dates ! to quad-word integers to do the calculations in "clunks", then ! back to dates for formatting output ! Q1 = D1 ! have to convert days to quads Q2 = D2 Q3 = Q2 - Q1 ! Number of days interval IF Q3 < 0 THEN Q3 = 1 ! any date in the future becomes yesterday !N = Q3 / 864000000000 ! convert clunks to days N = D2 - D1 ! get whole days here ! PRINT SKIP, " You are ", N (-) USING ZZ,ZZ9, " days old." ! REPEAT 28 BEGIN ! store data for 14 days by half day N = Q3 / 864000000000 ! convert clunks to days ! ! Convert number of days to radians by multiplying by 2 PI and ! dividing by the number of days in the cycle (because SINE wants ! it's argument in radians). ! P = FN$SIN(N * 0.273182) S = FN$SIN(N * 0.2243995) I = FN$SIN(N * 0.1903996) ! D3 = Q1 + Q3 ! convert clunks back to date ! ! store the data ! STORE BIO_DAT USING BEGIN ! into new or empty file DAY = D3 P = P S = S I = I PRINT_STRING = BLANK END ! Q3 = Q3 + 432000000000 ! go to next half day (in clunks) END ! ! Now go back over the data and make the print string into a ! horizontal graph. ! FOR BIO_DAT BEGIN ! ! Scale the variables to fit a -25 to +25 graph (51 print positions) ! IP = FN$NINT(P * 25) IS = FN$NINT(S * 25) II = FN$NINT(I * 25) ! ! Run through the graph and find out where things print. ! ! Note the use of the re-defined field to treat PRINT_STRING as an array. ! J = -25 FOR PRINT_CHAR MODIFY USING BEGIN IF IP = J THEN CHAR = "P" IF IS = J THEN CHAR = "S" IF II = J THEN CHAR = "I" J = J + 1 END END ! ! Now all that has to be done is to print it out. ! REPORT BIO_DAT ON *."file name or TT " SET COLUMNS_PAGE = 72 AT TOP OF REPORT PRINT "Biorhythm chart for a birthdate of", SPACE 1, D1 USING W(9)BDD_MMM_YYYY, SKIP 2, COL 29, "(-) (0) (+)" PRINT COL 2, CHOICE ! print date for only one FN$HOUR(DAY) = 0 THEN DAY ! of the two data points ELSE " " END_CHOICE USING WWWBNN/DD, SPACE 2, PRINT_STRING AT BOTTOM OF REPORT PRINT SKIP 2 END_REPORT ! END_PROCEDURE DELETE PRINT_BIO; REDEFINE PROCEDURE PRINT_BIO ! !SET COLUMNS_PAGE = 72 ! ! Calculate biorhythms for a given birthdate starting with "TODAY" and ! going on for 14 days, 2 values per day (midnight and noon). ! Try printing without an intermediate file. ! ! B. Z. Lederman ! ! Need some temporary variables ! DECLARE P USAGE REAL EDIT_STRING S9.999. DECLARE S USAGE REAL EDIT_STRING S9.999. DECLARE I USAGE REAL EDIT_STRING S9.999. DECLARE IP USAGE INTEGER. DECLARE IS USAGE INTEGER. DECLARE II USAGE INTEGER. DECLARE J USAGE INTEGER. DECLARE N PIC S9999999V9 EDIT_STRING Z,ZZZ,ZZZ.9. ! ! There are extra date fields so we can set the start and end dates ! (eventually). ! DECLARE D1 USAGE DATE. DECLARE D2 USAGE DATE. DECLARE D3 USAGE DATE. DECLARE Q1 USAGE QUAD. DECLARE Q2 USAGE QUAD. DECLARE Q3 USAGE QUAD. ! ! Used to format the "graph" ! DECLARE CHAR PIC X. DECLARE LINE PIC X(51). !line = " : " ! ! Get the subject's birthday, and today's date. ! D1 = *."your birthday" D2 = "TODAY" Q1 = D1 ! have to convert days to quads Q2 = D2 Q3 = Q2 - Q1 ! Number of days interval IF Q3 < 0 THEN Q3 = 1 ! any date in the future becomes yesterday N = Q3 / 864000000000 ! convert clunks to days PRINT " You are ", N USING ZZ,ZZ9, " days old.", SKIP ! PRINT "Biorhythm chart for a birthdate of", SPACE 1, ! D1 USING W(9)BNN/DD/YYYY, SKIP 2, ! numeric only D1 USING W(9)BDD_MMM_YYYY, SKIP 2, ! this looks nicer COL 29, "(-) (0) (+)" ! chart header ! REPEAT 28 BEGIN ! store data for 14 days by half day N = Q3 / 864000000000 ! convert clunks to days ! ! Convert number of days to radians by multiplying by 2 PI and ! dividing by the number of days in the cycle ! P = FN$SIN(N * 0.273182) S = FN$SIN(N * 0.2243995) I = FN$SIN(N * 0.1903996) ! ! Scale the variables to fit a -25 to +25 graph (51 print positions) ! IP = FN$NINT(P * 25) IS = FN$NINT(S * 25) II = FN$NINT(I * 25) ! D3 = Q1 + Q3 ! convert clunks back to date ! ! LINE = "" ! ! ! Run through the graph and find out where things print. ! We should eventually check for two characters in the same ! column at the same time. ! J = -25 WHILE J LE 25 BEGIN CHAR = " " IF J = 0 THEN CHAR = ":" IF IP = J THEN CHAR = "P" IF IS = J THEN CHAR = "S" IF II = J THEN CHAR = "I" LINE = LINE | CHAR J = J + 1 END ! PRINT COL 2, CHOICE ! print date for only one FN$HOUR(D3) = 0 THEN D3 ! of the two data points ELSE " " END_CHOICE USING WWWBNN/DD, SPACE 2, LINE (-) !