[fpc-pascal] best method: multiple three state options in a decision tree

waldo kitty wkitty42 at windstream.net
Mon Jan 27 17:41:59 CET 2014


On 1/27/2014 4:57 AM, Lukasz Sokol wrote:
> On 24/01/14 16:20, waldo kitty wrote:
>> with the above epiphany and some other information i have acquired,
>> i'm now in the process of rewriting the app... i suspect it will take
>> me a day or two to get to the point i was at previously with the
>> operational and in-use code but i still wanted to say thanks to you
>> and others who provided ideas, insights and information ;) :)
>>
>
> Glad to hear that not all I thought of is a brain fart ;)

definitely not a brain fart... it was very helpful ;)

> However I'm still curious : why use bits directly, when you can have a
> set/'enum' of possible choice(s), guaranteed to be distinct - so you can't
> physically set OptionA twice, by definition, and then make the Options be an
> array of the options?

well, i can't set any option more than once, anyway... not unless i make a code 
error and set or clear the wrong bit but that will be noticed very quickly 
during testing ;)  for readability, i find setting the bits and then running 
down a simple CASE statement much easier to follow... especially since i wrote 
my code generator tool that creates the CASE statement and all of its valid 
selections ;)

> Yes it may be using Sizeof(set) x num options (1 byte per option?)

yeah, i don't know... i'm very old school and like to keep things as tight as 
possible... being able to store all the options we've been discussing in one 
16bit "device" is a good thing... that i can also simply use that "device" as a 
decimal number for the selectors in a CASE statement is a major good thing... no 
matter what i do, i can't get away from the CASE statement...  well, i could by 
using a use tree of if/then/else but that's what i started with and it was not 
readable at all... the CASE statement "decision tree" is nice but i can't see 
how to use it with the sets of enums in an easy way...

> but then it's not for you to worry any more about the bits - the compiler
> will care for that and you can go rethink the logic ;) and also readability
> and maintainability +100 ;)

once i get finished, this will be pretty much done and then i can move on to the 
larger application that this will eventually be a part of... i'm debating as to 
whether to keep this part as a separate binary or to build it all into one large 
monolithic app with the other parts... eventually i will be doing something with 
graphics which is going to be a whole new world for me to make mistakes in... 
and it is planned for all of this to by multi-platform, was well... data 
retrieval built-in along with the current merging and list output capabilities 
and then actually drawing the output on one of two graphical screens... one 
looking down at earth and the other looking up from earth... i should probably 
quit while i'm a head :LOL:

> But IMHO of course and YMMV ;)

very true :)

-- 
NOTE: No off-list assistance is given without prior approval.
       Please keep mailing list traffic on the list unless
       private contact is specifically requested and granted.



More information about the fpc-pascal mailing list