Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WHAT IS WRONG WITH THIS SCRIPT?!?!
#11
Quote:Could someone please tell me what i'm doin wrong here!!
I type the following script in and then get the message 'Block IF without END IF' and cant run my script

THE SCRIPT:

INPUT "choice", mainmenu%
IF mainmenu% = 1 THEN
GOTO 1
.
.
.
IF mainmenu% = 2 THEN
GOTO 6
ELSE
GOTO 7
END IF

PLEASE HELP!!!!!!!!!!

The following is how block if then is structured...note the ELSE IF...your original code had 7 nested block if then statements...you needed 7 END IF statements to make it work...

INPUT "choice", variable

IF variable = 1 THEN
do this stuff
ELSE IF variable = 2 THEN
do this stuff
ELSE
do this
END IF


read the manual is good advice...and look at other people's code...and experiment...
Reply
#12
Quote:
Code:
IF mainmenu% >= 1 THEN IF mainmenu% <= 6 THEN ON mainmenu% GOTO 1, 2, 3, 4, 5, 6

Dude... You saved me some room in the program i was working on! Thanx! :o
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#13
Quote:
Agamemnus Wrote:
Code:
IF mainmenu% >= 1 THEN IF mainmenu% <= 6 THEN ON mainmenu% GOTO 1, 2, 3, 4, 5, 6

Dude... You saved me some room in the program i was working on! Thanx! :o

You'll save even more room if you change that THEN IF to an AND Wink
In a world without walls and doors, who needs Windows and Gates?
Reply
#14
I was thinking the same thing Piptol but before I could post that, I came across Rel's post from a long while ago:

Quote:Seph:

Slow:

Code:
if X=0 and Y=1 and Z=3 then
     End if

Faster: (They call this "Short Circuit"

Code:
If X=0 then
        if Y=1 then
             if Z=3 then
             End if
        End if
   End if
earn.
Reply
#15
Hmm, guess I should have known that from C++. For some reason though I didn't think it worked like that in QB. Oh well, I bow to rel's genius (on this occassion, at least) Wink
In a world without walls and doors, who needs Windows and Gates?
Reply
#16
And it only takes a few lines of code to convert from a AND b to IF THEN b.

Pitiful.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#17
so ut's faster to do it the Short Circuit way?
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#18
As I remember someone else saying, QB first reads the WHOLE IF part of the statement then evaluates the WHOLE statement instead of reordering any parentheses and evaluating it incrementally.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#19
Quote:
whitetiger0990 Wrote:
Agamemnus Wrote:
Code:
IF mainmenu% >= 1 THEN IF mainmenu% <= 6 THEN ON mainmenu% GOTO 1, 2, 3, 4, 5, 6

Dude... You saved me some room in the program i was working on! Thanx! :o

You'll save even more room if you change that THEN IF to an AND Wink
Quote:
Code:
IF mainmenu% >= 1 AND mainmenu% <= 6 THEN ON mainmenu% GOTO 1, 2, 3, 4, 5, 6
Tongue

Obviously didn't see my earlier post then :/
url=http://www.spreadfirefox.com/?q=affiliates&id=60131&t=79][Image: safer.gif][/url]
END OF LINE.
Reply
#20
I am still confused. So if you use:

Code:
IF a = 1 AND b = 1 THEN c = 1

it is faster then

Code:
IF a = 1 THEN IF b = 1 THEN c = 1

:???:
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)