Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_IIF limits two questions
#16
Honestly, I like this old code better than the _IIF statement:

    'IF n.ac THEN '                                              If note enharmonic
    '    IF Vtog%(shrp_flt) THEN '                              If in flat mode
    '        NoteName$ = n.bf
    '    ELSE '                                                  If in sharp mode
    '        NoteName$ = n.bs
    '    END IF
    'ELSE '                                                      If note NOT enharmonic
    '    NoteName$ = n.nt
    'END IF

Things are spread out on multiple lines and each segment is commented to help understand what it's supposed to be doing.  I'd personally find the above much easier to maintain and work with after a 6 month break, where I might find myself having to go back and rework the code for some error or new enhancement, than I would the _IFF alternative.

NoteName$ = _IIF(n.ac, _IIF(Vtog%(shrp_flt), n.bf, n.bs), n.nt)

There's a lot less code there for you to write and work with, but also a lot less explanation of what's going on with that code.  It's just user defined types which you might not remember what every element stands for in the future, and arrays and indexes, and... a huge question mark which says, "WTF WAS THIS DOING?!!"

It may save you a few bytes disk space and compact the code down a byte or two, but you have to consider if it's going to be worth the hit to readability and maintenance with the future of the code.  Over the years, I've thrown together a LOT of quick and sloppy code, and been proud of it at the time, only to have to almost rewrite the whole thing from scratch a couple years later just because I couldn't figure out my own damn flow and logic with stuff.  LOL!

My opinion with _IFF is that it's convenient, but it's a tool that I'd personally tend to use for fairly obvious stuff which isn't hard to decipher and doesn't need any comments to sort out.  It's something I personally find just too murky to understand for complex stuff.   If you need comments, in my opinion, it's probably best to use an IF structure and lay out those comments at the various blocks as you've did with the original code.

Your future self will thank you.  Big Grin  At least, mine usually does.  Wink
Reply


Messages In This Thread
_IIF limits two questions - by doppler - 12-20-2024, 07:06 PM
RE: _IIF limits two questions - by Petr - 12-20-2024, 08:03 PM
RE: _IIF limits two questions - by bplus - 12-20-2024, 09:07 PM
RE: _IIF limits two questions - by doppler - 12-21-2024, 02:00 AM
RE: _IIF limits two questions - by Pete - 12-20-2024, 11:44 PM
RE: _IIF limits two questions - by Pete - 12-21-2024, 12:02 AM
RE: _IIF limits two questions - by madscijr - 12-22-2024, 08:49 PM
RE: _IIF limits two questions - by bplus - 12-21-2024, 02:56 AM
RE: _IIF limits two questions - by a740g - 12-23-2024, 01:15 AM
RE: _IIF limits two questions - by madscijr - 12-23-2024, 03:53 AM
RE: _IIF limits two questions - by NakedApe - 01-20-2025, 01:19 AM
RE: _IIF limits two questions - by OldMoses - 05-13-2025, 05:11 PM
RE: _IIF limits two questions - by a740g - 05-13-2025, 10:51 PM
RE: _IIF limits two questions - by OldMoses - 05-13-2025, 11:38 PM
RE: _IIF limits two questions - by madscijr - 05-13-2025, 11:48 PM
RE: _IIF limits two questions - by SMcNeill - 05-13-2025, 11:55 PM
RE: _IIF limits two questions - by madscijr - 05-14-2025, 05:31 AM
RE: _IIF limits two questions - by CharlieJV - 05-14-2025, 12:56 PM
RE: _IIF limits two questions - by madscijr - 05-14-2025, 04:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  What limits you? Unseen Machine 9 1,018 09-05-2025, 01:32 AM
Last Post: madscijr
  Half baked pipe dream questions - hardware and os Parkland 9 1,331 05-23-2025, 03:00 PM
Last Post: madscijr
  IDE suggestions / editor questions madscijr 14 2,356 05-01-2025, 12:56 PM
Last Post: madscijr
  Questions about INSTR Circlotron 7 1,032 04-27-2025, 03:12 PM
Last Post: mdijkens
  Just a Few Questions TarotRedhand 15 2,881 09-11-2023, 12:10 PM
Last Post: DSMan195276

Forum Jump:


Users browsing this thread: 1 Guest(s)