05-09-2022, 02:54 AM
(05-09-2022, 01:39 AM)PhilOfPerth Wrote: Then I don't get it! If ANY combinations will give 255, what's the point of it, and how could it be used (if I wanted to)? Can you show a (simple) example?
A working demo of IMP, for you:
Code: (Select All)
Dim Man As _Byte, Healthy As _Byte 'our two variables we're going to IMP
Print "Let's determine if you're eligable for a discount for medical insurance."
Print "All women are eligible, as are all healthy men."
Print "Men with pre-existing conditions aren't included in this discount."
Do
Print
Print
Input "Are you a man (Y/N)", Man$
Input "Are you healthy (Y/N)", Health$
If InStr(UCase$(Man$), "Y") Then Man = -1 Else Man = 0
If InStr(UCase$(Health$), "Y") Then Healthy = -1 Else Healthy = 0
Print Man, Healthy
Discount = Man Imp Healthy
If Discount Then Print "You qualify!" Else Print "Unhealthy males don't qualify!"
Loop Until Man$ = ""
Run that a few times and try the various combinations for being a man and being healthy, and remember the rules we set for who qualifies for the insurance discount..
If a man and healthy -- you qualify!
if a man and not healthy -- you don't qualify!
if a woman and healthy -- you qualify!
if a woman and not healthy -- you qualify!
Discount = Man IMP Healthy
As I mentioned in my first post, this is nothing more than a fancy way of writing: Discount = NOT Man OR Healthy
Swap out that IMP statement for the one above and then run the program again, if you'd like. Discount = NOT Man OR Healthy runs the exact same as Discount = Man IMP Healthy.