Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Multiple results on a conditional statement

Author
Message
Visvalor
15
Years of Service
User Offline
Joined: 29th Dec 2010
Location:
Posted: 29th Dec 2010 18:52


I want to click an image, highlight the image then go to a sub. How do I get it to go to the sub AND highlight the image (By replacing the image)

Code attached for review, thanks

"Tis better to die on your feet, than live on your knees" - Emilio Zapato
Lucas Tiridath
AGK Developer
17
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 29th Dec 2010 19:52 Edited at: 29th Dec 2010 19:53
Hi. Using your code, you can achieve what you want by adding a colon between your commands. However this isn't good practise as you will often need multiple commands in selection statements. Instead, you should use the fully expanded version of the if statement. This would make your code look like this:



The difference is that you remove the then keyword. This will mean that rather than just executing a command on the same line, the selection will carry out all the commands until it hits the endif keyword.

Hope this helps.
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 29th Dec 2010 21:01
also, keep in mind you wrote "then gosub pass_test and paste image 3, 20, 20"

the *and* operator is what's called a boolean operator. Boolean values are either true or false, 1 or 0.

1 and 0 = 0
0 and 1 = 0
0 and 0 = 0
1 and 1 = 1

The less than operator is also a boolean operator, because it returns a zero or a 1. So it only would make sense to do something like you're doing, if you had function1() and function2() that both returned values, IE:
if blah<foo then myBooleanValue=function1() and function2()
This would make myBooleanValue either 1 or 0, and both function1 and function2 would be called.

Visvalor
15
Years of Service
User Offline
Joined: 29th Dec 2010
Location:
Posted: 29th Dec 2010 23:12
Well I was using "and" as a literal statement. I'm a bit of a noob. Thanks for the help !

"Tis better to die on your feet, than live on your knees" - Emilio Zapato

Login to post a reply

Server time is: 2026-07-18 07:32:29
Your offset time is: 2026-07-18 07:32:29