Qbasicnews.com

Full Version: Answer My Question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If slot1$ = "Bronze" then point = point + 2 ELSE
If slot2$ = "Bronze" then point = point + 2 ELSE
If slot3$ = "Bronze" then point = point + 2

Alright there is suppose to be 3 slots when I run the program, if just one slot pops up "bronze" then the player gets 2 points. That's pretty simple & so far it works. Now if two slots get the same "Bronzes" then the player gets 5 points, the problem I'm having is when the "Bronze" gets in 2 slots I only get 4 points I think it's because Bronze + Bronze = the result is 4, I want it to be 5. I was thinking about doing this code but I don't know how to do it correctly.

if slot1$ and slot2$ = "bronze" then point = point + 5

Please explain in the simpless forum thank you ahead of time, Gin
you've pretty much got it there, just put it into basic

if slot1$ = "bronze" and slot2$ = "bronze" then
point = point + 5
'checks for both slot 1 and 2

elseif slot1$ = "Bronze" then
point = point + 2
'checks for just slot 1

elseif slot2$ = "Bronze" then
point = point + 2
'checks for just slot 2

elseif slot3$ = "Bronze" then
point = point + 2
'checks for just slot3

end if

keep adding more cases if you want more combinations
May I introduce you to XOR.

A better way would be:

Code:
IF slot1$ = "bronze" AND slot2$ = "bronze" THEN
  point = point + 5
ELSE
  IF slot1$ = "bronze" XOR slot2$ = "bronze" XOR slot3$ = "bronze" THEN point = point + 2
END IF

Here is Logical operators:
AND: You say IF any are FALSE then the IF is FALSE
First | Second| Result| (In binary 0 = FALSE, 1 = TRUE (accually non-zero is true...but...))
1|1|1
1|0|0
0|1|0
0|0|0

OR: You say IF any are TRUE then the IF is TRUE
1|1|1
1|0|1
0|1|1
0|0|0

XOR: You say IF and ONLY IF 1 is TRUE then the if is TRUE
1|1|0
1|0|1
0|1|1
0|0|0

NOT: The opposite boolean
Makes 10 and 01
1|0
0|1