Jack Kelly
New Member
I see no benefit from anonymity.
Posts: 19
|
Post by Jack Kelly on Jun 9, 2024 9:10:13 GMT -5
If you're wondering why I need all these code routines, it's because programming keeps me sane. It's the only thing that keeps me sane nowadays. Right now I'm working on a Windows 7 public PC in the basement of my apartment building. It's okay. I can do just about everything I need to do. For the umpteenth time I've lost my personal PC and all my life's work that was in it. Oh well, it can be good to restart from scratch. We're always wiser the next time around. Thanks for being my friends.
|
|
|
Post by Rod on Jun 9, 2024 9:22:29 GMT -5
Go and buy as big a usb memory stick as you can afford and start using it. Buy two, keep a copy. Then it matters not a jot what pc you use. Just plug in your life’s work.
I have terabyte hard drive that has almost everything I have worked on, it is not full but it is making whirring sounds so I have acted on my own advice and do have usb based backup.
|
|
Jack Kelly
New Member
I see no benefit from anonymity.
Posts: 19
|
Post by Jack Kelly on Jun 9, 2024 11:21:49 GMT -5
Thank you for your sensible advice, Rod. I will heed it. Here's another try with my recent code -- more useful for Americans. Sorry.
NoMainWin global ThisYear, NextYear, LastYear WindowWidth=850 WindowHeight=800 BackgroundColor$ = "191 191 255" ' buttonface default ThisYear$=left$(Date$("yyyy/mm/dd"), 4): ThisYear=val(ThisYear$) NextYear = ThisYear + 1: LastYear = ThisYear - 1 Year = ThisYear: Year$ = str$(Year) ListBoxArray$(0) = "This Year" ListBoxArray$(1) = "Next Year" ListBoxArray$(2) = "Last Year"
StaticText #1.Debug "", 0, 0, 600, 20 StaticText #1.StaticText "", 50, 50, 300, 40 ListBox #1.ListBox ListBoxArray$(), [ListBoxClick], 350, 25, 100, 70 Button #1.Quit "Quit", [Quit], UL, 700, 390, 80, 40 TextEditor #1.TextEditor 50, 100, 600, 600
open "ANNUAL HOLIDAYS" for dialog as #1 #1 "TrapClose [Quit]" #1 "Font Ariel 12 Bold" #1.StaticText "!Font Ariel 16 Bold" #1.ListBox "SingleClickSelect" #1.ListBox "SelectIndex 1"
call DisplayHolidays Year wait
sub DisplayHolidays Year Year$ = str$(Year) #1.StaticText "Holidays in " + Year$ #1.TextEditor "!cls" #1.TextEditor "Martin Luther King Day is January " + str$(NthDayOfMonth(Year,01,"3mo")) #1.TextEditor "Super Bowl Sunday is February " + str$(NthDayOfMonth(Year,02,"2su")) #1.TextEditor "Presidents Day is February " + str$(NthDayOfMonth(Year,02,"3mo")) #1.TextEditor "Mothers Day is May " + str$(NthDayOfMonth(Year,05,"2su")) #1.TextEditor "Memorial Day is May " + str$(NthDayOfMonth(Year,05,"Lmo")) #1.TextEditor "Fathers Day is June " + str$(NthDayOfMonth(Year,06,"3su")) #1.TextEditor "Labor Day is September " + str$(NthDayOfMonth(Year,09,"1mo")) #1.TextEditor "Columbus Day is October " + str$(NthDayOfMonth(Year,10,"2mo")) #1.TextEditor "Election Day tomorrow is November " + str$(NthDayOfMonth(Year,11,"1mo")) #1.TextEditor "Veterans Day (observed) is November " + str$(NthDayOfMonth(Year,11,"2mo")) #1.TextEditor "Thanksgiving is November " + str$(NthDayOfMonth(Year,11,"4th")) #1.TextEditor "" AW$ = date$(Easter(Year) - 46): AWmonth = val(left$(AW$,2)): AWday = val(mid$(AW$,4,2)) if AWmonth = 2 then AWmonth$ = "February " if AWmonth = 3 then AWmonth$ = "March " #1.TextEditor "Ash Wednesday is " + AWmonth$ + str$(AWday) #1.TextEditor "Easter is " + Easter$(Year) #1.TextEditor "" #1.TextEditor "New Year's Day, January 1, is on a " + DayOfDateFull$(Year$ + "0101") #1.TextEditor "Groundhog Day, February 2, is on a " + DayOfDateFull$(Year$ + "0202") #1.TextEditor "Lincoln's Birthday, February 12, is on a " + DayOfDateFull$(Year$ + "0212") #1.TextEditor "Valentine's Day, February 14, is on a " + DayOfDateFull$(Year$ + "0214") #1.TextEditor "St. Patrick's Day, March 17, is on a " + DayOfDateFull$(Year$ + "0317") #1.TextEditor "April Fool's Day, April 1, is on a " + DayOfDateFull$(Year$ + "0401") #1.TextEditor "Juneteenth, June 19, is on a " + DayOfDateFull$(Year$ + "0619") #1.TextEditor "Independence Day, July 4, is on a " + DayOfDateFull$(Year$ + "0704") #1.TextEditor "Halloween, October 31, is on a " + DayOfDateFull$(Year$ + "1031") #1.TextEditor "Veteran's Day, November 11, is on a " + DayOfDateFull$(Year$ + "1111") #1.TextEditor "Christmas Day, December 25, is on a " + DayOfDateFull$(Year$ + "1225") #1.TextEditor "New Year's Eve, December 31, is on a " + DayOfDateFull$(Year$ + "1231") end sub
[ListBoxClick] #1.ListBox "SelectionIndex? SelIx" select case SelIx case 1: Year = ThisYear case 2: Year = NextYear case 3: Year = LastYear end select call DisplayHolidays Year wait
[Quit] close #1 end wait
function NthDayOfMonth(yyyy, mm, nda$) ' nda$ is a two-part code. The first character, n, denotes ' first, second, third, fourth, and last by 1, 2, 3, 4, or L. ' The last two characters, da, denote the day of the week by ' mo, tu, we, th, fr, sa, or su. For example: ' the nda$ for the second Monday of a month is "2mo"; ' the nda$ for the last Thursday of a month is "Lth". if yyyy<1900 or yyyy>2099 or mm<1 or mm>12 then NthDayOfMonth=0: exit function end if nda$=lower$(trim$(nda$)) if len(nda$)<>3 then NthDayOfMonth=0: exit function n$=left$(nda$,1): nC$="1234l" da$=right$(nda$,2): daC$="tuwethfrsasumotuwethfrsasumo" if not(instr(nC$,n$)) or not(instr(daC$,da$)) then NthDayOfMonth=0: exit function end if NthDayOfMonth=1 mm$=str$(mm): if mm<10 then mm$="0"+mm$ db$=DayOfDate$(str$(yyyy)+mm$+"01") if da$<>db$ then x=instr(daC$,db$): y=instr(daC$,da$,x): NthDayOfMonth=1+(y-x)/2 end if dim MD(12) MD(1)=31: MD(2)=28: MD(3)=31: MD(4)=30: MD(5)=31: MD(6)=30 MD(7)=31: MD(8)=31: MD(9)=30: MD(10)=31: MD(11)=30: MD(12)=31 if yyyy mod 4 = 0 then MD(2)=29 if n$<>"1" then if n$<>"l" then NthDayOfMonth=NthDayOfMonth+((val(n$)-1)*7) else if NthDayOfMonth+27<MD(mm) then NthDayOfMonth=NthDayOfMonth+28 else NthDayOfMonth=NthDayOfMonth+21 end if end if end if end function
function DayOfDateFull$(ObjectDate$) 'yyyymmdd format if ObjectDate$="" then 'today DaysSince1900 = date$("days") else DaysSince1900 = date$(mid$(ObjectDate$,5,2)+"/"+right$(ObjectDate$,2)_ +"/"+left$(ObjectDate$,4)) end if DayOfWeek = DaysSince1900 mod 7 select case DayOfWeek case 0: DayOfDateFull$="Tuesday" case 1: DayOfDateFull$="Wednesday" case 2: DayOfDateFull$="Thursday" case 3: DayOfDateFull$="Friday" case 4: DayOfDateFull$="Saturday" case 5: DayOfDateFull$="Sunday" case 6: DayOfDateFull$="Monday" end select end function
function DayOfDate$(ObjectDate$) 'yyyymmdd format if ObjectDate$="" then 'today DaysSince1900 = date$("days") else DaysSince1900 = date$(mid$(ObjectDate$,5,2)+"/"+right$(ObjectDate$,2)_ +"/"+left$(ObjectDate$,4)) end if DayOfWeek = DaysSince1900 mod 7 select case DayOfWeek case 0: DayOfDate$="tu" case 1: DayOfDate$="we" case 2: DayOfDate$="th" case 3: DayOfDate$="fr" case 4: DayOfDate$="sa" case 5: DayOfDate$="su" case 6: DayOfDate$="mo" end select end function
function Easter(year) ' "yyyy", returns day number gn = year mod 19 + 1 ' Golden Number c = int(year /100) +1 ' Century JE = ( 11 *(gn -1)) mod 30 ' Julian Epact # S = int(3 *c /4) ' Solar Equation ( 3 non-leap days every 4 centuries) L = int( (8 *c +5) /25) ' Lunar Equation ( 8 days every 25 centuries) GE = JE - S + L + 8 ' Gregorian Epact # if GE <1 then GE = GE + 30*(1 + int(abs(GE)/30)) GE = GE mod 30
if GE <= 23 then efm = 44 - GE ' efm = Ecclesiastical full moon ( 22=Mar 22nd, 32=Apr 1st, etc.) if GE > 23 then efm = 74 - GE if (GE =24) or (GE =25 and gn >11) then efm = efm - 1
wd = (efm + 2 + year + int(year/4) - int(year/100) + int(year/400)) mod 7 ed = efm + 7 - wd ' Easter Day = first Sunday after EFM mm = 3 + int(ed/32) dd = ed - 31*int(mm/4) if mm = 3 then mm$ = "March " if mm = 4 then mm$ = "April " Easter$ = mm$ + str$(dd) Easter = date$(mm$ + "/" + str$(dd) + "/" + str$(year)) end function
function Easter$(year) ' "yyyy", returns "m/d" gn = year mod 19 + 1 ' Golden Number c = int(year /100) +1 ' Century JE = ( 11 *(gn -1)) mod 30 ' Julian Epact # S = int(3 *c /4) ' Solar Equation ( 3 non-leap days every 4 centuries) L = int( (8 *c +5) /25) ' Lunar Equation ( 8 days every 25 centuries) GE = JE - S + L + 8 ' Gregorian Epact # if GE <1 then GE = GE + 30*(1 + int(abs(GE)/30)) GE = GE mod 30
if GE <= 23 then efm = 44 - GE ' efm = Ecclesiastical full moon ( 22=Mar 22nd, 32=Apr 1st, etc.) if GE > 23 then efm = 74 - GE if (GE =24) or (GE =25 and gn >11) then efm = efm - 1
wd = (efm + 2 + year + int(year/4) - int(year/100) + int(year/400)) mod 7 ed = efm + 7 - wd ' Easter Day = first Sunday after EFM mm = 3 + int(ed/32) dd = ed - 31*int(mm/4) if mm = 3 then mm$ = "March " if mm = 4 then mm$ = "April " Easter$ = mm$ + str$(dd) Easter = date$(mm$ + "/" + str$(dd) + "/" + str$(year)) end function
|
|
|
Post by tsh73 on Jun 10, 2024 9:53:27 GMT -5
Hello Jack small fix to work in JB too also, Wikipedia says Fathers day should be Third Sunday in June? NoMainWin global ThisYear, NextYear, LastYear WindowWidth=850 WindowHeight=800 BackgroundColor$ = "191 191 255" ' buttonface default 'ThisYear$=left$(Date$("yyyymmddd"), 4) ThisYear$=left$(Date$("yyyy/mm/dd"), 4) 'JB ThisYear=val(ThisYear$) NextYear = ThisYear + 1: LastYear = ThisYear - 1 Year = ThisYear: Year$ = str$(Year) ListBoxArray$(0) = "This Year" ListBoxArray$(1) = "Next Year" ListBoxArray$(2) = "Last Year"
StaticText #1.Debug "", 0, 0, 600, 20 StaticText #1.StaticText "", 50, 50, 300, 40 ListBox #1.ListBox ListBoxArray$(), ListBoxClick, 350, 25, 100, 70 Button #1.Quit "Quit", Quit, UL, 700, 390, 80, 40 TextEditor #1.TextEditor 50, 100, 600, 600
open "ANNUAL HOLIDAYS" for dialog as #1 #1 "TrapClose Quit" #1 "Font Ariel 12 Bold" #1.StaticText "!Font Ariel 16 Bold" #1.ListBox "SingleClickSelect" #1.ListBox "SelectIndex 1"
call DisplayHolidays Year wait
sub DisplayHolidays Year Year$ = str$(Year) #1.StaticText "Holidays in " + Year$ #1.TextEditor "!cls" #1.TextEditor "Martin Luther King Day is January " + str$(NthDayOfMonth(Year,01,"3mo")) #1.TextEditor "Super Bowl Sunday is February " + str$(NthDayOfMonth(Year,02,"2su")) #1.TextEditor "Presidents Day is February " + str$(NthDayOfMonth(Year,02,"3mo")) #1.TextEditor "Mothers Day is May " + str$(NthDayOfMonth(Year,05,"2su")) #1.TextEditor "Memorial Day is May " + str$(NthDayOfMonth(Year,05,"Lmo")) #1.TextEditor "Fathers Day is June " + str$(NthDayOfMonth(Year,06,"2su")) #1.TextEditor "Labor Day is September " + str$(NthDayOfMonth(Year,09,"1mo")) #1.TextEditor "Columbus Day is October " + str$(NthDayOfMonth(Year,10,"2mo")) #1.TextEditor "Election Day tomorrow is November " + str$(NthDayOfMonth(Year,11,"1mo")) #1.TextEditor "Veterans Day (observed) is November " + str$(NthDayOfMonth(Year,11,"2mo")) #1.TextEditor "Thanksgiving is November " + str$(NthDayOfMonth(Year,11,"4th")) #1.TextEditor "" AW$ = date$(Easter(Year) - 46): AWmonth = val(left$(AW$,2)): AWday = val(mid$(AW$,4,2)) if AWmonth = 2 then AWmonth$ = "February " if AWmonth = 3 then AWmonth$ = "March " #1.TextEditor "Ash Wednesday is " + AWmonth$ + str$(AWday) #1.TextEditor "Easter is " + Easter$(Year) #1.TextEditor "" #1.TextEditor "New Year's Day, January 1, is on a " + DayOfDateFull$(Year$ + "0101") #1.TextEditor "Groundhog Day, February 2, is on a " + DayOfDateFull$(Year$ + "0202") #1.TextEditor "Lincoln's Birthday, February 12, is on a " + DayOfDateFull$(Year$ + "0212") #1.TextEditor "Valentine's Day, February 14, is on a " + DayOfDateFull$(Year$ + "0214") #1.TextEditor "St. Patrick's Day, March 17, is on a " + DayOfDateFull$(Year$ + "0317") #1.TextEditor "April Fool's Day, April 1, is on a " + DayOfDateFull$(Year$ + "0401") #1.TextEditor "Juneteenth, June 19, is on a " + DayOfDateFull$(Year$ + "0619") #1.TextEditor "Independence Day, July 4, is on a " + DayOfDateFull$(Year$ + "0704") #1.TextEditor "Halloween, October 31, is on a " + DayOfDateFull$(Year$ + "1031") #1.TextEditor "Veteran's Day, November 11, is on a " + DayOfDateFull$(Year$ + "1111") #1.TextEditor "Christmas Day, December 25, is on a " + DayOfDateFull$(Year$ + "1225") #1.TextEditor "New Year's Eve, December 31, is on a " + DayOfDateFull$(Year$ + "1231") end sub
'sub ListBoxClick sub ListBoxClick handle$ 'JB #1.ListBox "SelectionIndex? SelIx" select case SelIx case 1: Year = ThisYear case 2: Year = NextYear case 3: Year = LastYear end select call DisplayHolidays Year end sub
'sub Quit sub Quit handle$ 'JB close #1 end end sub
function NthDayOfMonth(yyyy, mm, nda$) ' nda$ is a two-part code. The first character, n, denotes ' first, second, third, fourth, and last by 1, 2, 3, 4, or L. ' The last two characters, da, denote the day of the week by ' mo, tu, we, th, fr, sa, or su. For example: ' the nda$ for the second Monday of a month is "2mo"; ' the nda$ for the last Thursday of a month is "Lth". if yyyy<1900 or yyyy>2099 or mm<1 or mm>12 then NthDayOfMonth=0: exit function end if nda$=lower$(trim$(nda$)) if len(nda$)<>3 then NthDayOfMonth=0: exit function n$=left$(nda$,1): nC$="1234l" da$=right$(nda$,2): daC$="tuwethfrsasumotuwethfrsasumo" if not(instr(nC$,n$)) or not(instr(daC$,da$)) then NthDayOfMonth=0: exit function end if NthDayOfMonth=1 mm$=str$(mm): if mm<10 then mm$="0"+mm$ db$=DayOfDate$(str$(yyyy)+mm$+"01") if da$<>db$ then x=instr(daC$,db$): y=instr(daC$,da$,x): NthDayOfMonth=1+(y-x)/2 end if dim MD(12) MD(1)=31: MD(2)=28: MD(3)=31: MD(4)=30: MD(5)=31: MD(6)=30 MD(7)=31: MD(8)=31: MD(9)=30: MD(10)=31: MD(11)=30: MD(12)=31 if yyyy mod 4 = 0 then MD(2)=29 if n$<>"1" then if n$<>"l" then NthDayOfMonth=NthDayOfMonth+((val(n$)-1)*7) else if NthDayOfMonth+27<MD(mm) then NthDayOfMonth=NthDayOfMonth+28 else NthDayOfMonth=NthDayOfMonth+21 end if end if end if end function
function DayOfDateFull$(ObjectDate$) 'yyyymmdd format if ObjectDate$="" then 'today DaysSince1900 = date$("days") else DaysSince1900 = date$(mid$(ObjectDate$,5,2)+"/"+right$(ObjectDate$,2)_ +"/"+left$(ObjectDate$,4)) end if DayOfWeek = DaysSince1900 mod 7 select case DayOfWeek case 0: DayOfDateFull$="Tuesday" case 1: DayOfDateFull$="Wednesday" case 2: DayOfDateFull$="Thursday" case 3: DayOfDateFull$="Friday" case 4: DayOfDateFull$="Saturday" case 5: DayOfDateFull$="Sunday" case 6: DayOfDateFull$="Monday" end select end function
function DayOfDate$(ObjectDate$) 'yyyymmdd format if ObjectDate$="" then 'today DaysSince1900 = date$("days") else DaysSince1900 = date$(mid$(ObjectDate$,5,2)+"/"+right$(ObjectDate$,2)_ +"/"+left$(ObjectDate$,4)) end if DayOfWeek = DaysSince1900 mod 7 select case DayOfWeek case 0: DayOfDate$="tu" case 1: DayOfDate$="we" case 2: DayOfDate$="th" case 3: DayOfDate$="fr" case 4: DayOfDate$="sa" case 5: DayOfDate$="su" case 6: DayOfDate$="mo" end select end function
function Easter(year) ' "yyyy", returns day number gn = year mod 19 + 1 ' Golden Number c = int(year /100) +1 ' Century JE = ( 11 *(gn -1)) mod 30 ' Julian Epact # S = int(3 *c /4) ' Solar Equation ( 3 non-leap days every 4 centuries) L = int( (8 *c +5) /25) ' Lunar Equation ( 8 days every 25 centuries) GE = JE - S + L + 8 ' Gregorian Epact # if GE <1 then GE = GE + 30*(1 + int(abs(GE)/30)) GE = GE mod 30
if GE <= 23 then efm = 44 - GE ' efm = Ecclesiastical full moon ( 22=Mar 22nd, 32=Apr 1st, etc.) if GE > 23 then efm = 74 - GE if (GE =24) or (GE =25 and gn >11) then efm = efm - 1
wd = (efm + 2 + year + int(year/4) - int(year/100) + int(year/400)) mod 7 ed = efm + 7 - wd ' Easter Day = first Sunday after EFM mm = 3 + int(ed/32) dd = ed - 31*int(mm/4) if mm = 3 then mm$ = "March " if mm = 4 then mm$ = "April " Easter$ = mm$ + str$(dd) Easter = date$(mm$ + "/" + str$(dd) + "/" + str$(year)) end function
function Easter$(year) ' "yyyy", returns "m/d" gn = year mod 19 + 1 ' Golden Number c = int(year /100) +1 ' Century JE = ( 11 *(gn -1)) mod 30 ' Julian Epact # S = int(3 *c /4) ' Solar Equation ( 3 non-leap days every 4 centuries) L = int( (8 *c +5) /25) ' Lunar Equation ( 8 days every 25 centuries) GE = JE - S + L + 8 ' Gregorian Epact # if GE <1 then GE = GE + 30*(1 + int(abs(GE)/30)) GE = GE mod 30
if GE <= 23 then efm = 44 - GE ' efm = Ecclesiastical full moon ( 22=Mar 22nd, 32=Apr 1st, etc.) if GE > 23 then efm = 74 - GE if (GE =24) or (GE =25 and gn >11) then efm = efm - 1
wd = (efm + 2 + year + int(year/4) - int(year/100) + int(year/400)) mod 7 ed = efm + 7 - wd ' Easter Day = first Sunday after EFM mm = 3 + int(ed/32) dd = ed - 31*int(mm/4) if mm = 3 then mm$ = "March " if mm = 4 then mm$ = "April " Easter$ = mm$ + str$(dd) Easter = date$(mm$ + "/" + str$(dd) + "/" + str$(year)) end function
|
|
Jack Kelly
New Member
I see no benefit from anonymity.
Posts: 19
|
Post by Jack Kelly on Jun 10, 2024 17:26:05 GMT -5
Thank you, Anatoly, for your close attention and constructive comments. I appreciate it. I made the two changes in my copy of the code posting. ![:)](//storage.proboards.com/forum/images/smiley/smiley.png)
|
|
Jack Kelly
New Member
I see no benefit from anonymity.
Posts: 19
|
Post by Jack Kelly on Aug 9, 2024 9:35:30 GMT -5
I made a few changes to my program code in the previous posting on this thread. Hopefully it will now be compatible with LB45 and JB. Please try it and let me know if any problems. I apologize for any difficulties or confusion.
|
|