Qbasicnews.com
December 12, 2019, 02:19:17 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Answer My Question  (Read 1227 times)
The_Names_Gin
New Member

Posts: 21


« on: March 29, 2005, 05:14:18 PM »

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
Logged
potato
Ancient QBer
****
Posts: 409



WWW
« Reply #1 on: March 29, 2005, 05:22:01 PM »

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
Logged

ammit potato!
Mitth'raw'nuruodo
Ancient Guru
****
Posts: 515



WWW
« Reply #2 on: March 29, 2005, 07:02:42 PM »

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 1-->0 and 0-->1
1|0
0|1
Logged

i]"But...it was so beautifully done"[/i]
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!