08-16-2024, 03:21 AM
(08-15-2024, 06:06 PM)justsomeguy Wrote: You know I always want write clean, efficent code, but my muddled brain always ends making thing way more complicated and I feature creep.LOL, that's a perfect example of the "clever" code I spoke of earlier. It's beautiful code in its own strange way but come back to it a year later and it looks like an alien took a dump in the source, especially if every single stage of it is not documented well.
I start out thinking about doing this:
Code: (Select All)FUNCTION GetMonth$(month)
SELECT CASE month
CASE 1: GetMonth$ = "January"
...
END FUNCTION
I end up doing this.
Code: (Select All)month$ = "JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember."
DO
INPUT "Input a number between 1 and 12"; n%
i% = 1: m$ = "": DO
n% = n% + (INSTR("JFMASOND.", MID$(month$, i%, 1)) > 0)
m$ = _TRIM$(m$ + CHR$((ASC(MID$(month$, i%, 1)) * -(n% = 0)) + (32 * -(n% <> 0))))
i% = i% + 1: LOOP WHILE i% < LEN(month$) AND n% >= 0
PRINT m$
LOOP
Please don't think I'm making fun of your code. Just a perfect example of how some of our "feature creepy" minds work.