DOW - Happy Birthday, Merry Christmas, When?
#5
@dcromley As that function is only called once it could be eliminated entirely by changing your string to a constant

Code: (Select All)
CONST Months$ = "January  February March    April    May      June    July    August  SeptemberOctober  November December "

and then replacing the call to StringMonth$() in the line

Code: (Select All)
OutString$ = "The " + LTrim$(Str$(ADay%)) + Suffix$(ADay%) + " of " + StringMonth$(AMonth%) + " in " + LTrim$(Str$(AYear%)) + ", is/was on a "

with this line from your function StringMonthB$()

Code: (Select All)
_Trim$(Mid$(Months$, AMonth% * 9 - 8, 9))

Actually it is also possible to eliminate the function DayOfWeek%() in a similar manner as it too is only called once

Code: (Select All)
CONST WeekDay$ = "Sunday  Monday  Tuesday  WednesdayThursday Friday  Saturday "

by replacing the call to StringWeekDay$() in the line

Code: (Select All)
Print OutString$ + StringWeekDay$(DayNumber%) + "."

with a slightly edited version of your code

Code: (Select All)
_Trim$(Mid$(WeekDay$, DayNumber% * 9 - 8, 9))

But I personally think as both functions are only used once, I'll leave things as they are because I find them clearer to understand and with such a small program neither memory use nor execution speed is an issue.

Thanks for your interest.

TR
Reply


Messages In This Thread
RE: DOW - Happy Birthday, Merry Christmas, When? - by TarotRedhand - 05-24-2022, 07:20 PM



Users browsing this thread: 1 Guest(s)