Main forum > FAQ

ENDIF without IF

(1/3) > >>

ckrum:
Feeling like a newb
Here is the code..
IT PRODUCES AN ERROR - ENDIF without IF
THE 'IF' STATEMENT IS CLEARLY PRESENT SO IS THIS A BUG?
// --------------------------------- //
// Project: omgbug
// Start: Saturday, September 28, 2013
// IDE Version: 10.202
// SETCURRENTDIR("Media") // go to media files

DIM mynumber%[6]
//create an array of numbers for sort
mynumber%[1] = 5
mynumber%[2] = 3
mynumber%[3] = 1
mynumber%[4] = 2
mynumber%[5] = 6
mynumber%[6] = 4

//bubblesort the array
FOR a% = 1 TO 5
   FOR b% = a%+1 TO 6
       IF a%<>B% AND mynumber[a%] > mynumber[b%] THEN   
            memory%=mynumber%[b%]
           mynumber%[b%]=mynumber%[a%]
          mynumber%[a%]=memory%       
      ENDIF   
    NEXT
 NEXT
 
 FOR i%= 1 TO 6
 PRINT i% + " " + mynumber%[i%], 100 + (i%*20),100
 NEXT

erico:
Welcome.

It looks fine to me,
I think you don´t need that "THEN" on the IF line, only when you single line stuff.
For example:

If erico=coolguy then world=better

In your case, you have multiple results so:

If erico=coolguy
    world=better
    life=good
    ckrum=welcome
endif

I think that might be the answer.
You should also use the # up there the post window when posting code, makes it easier to test.
Like this:

--- Code: (glbasic) ---if codetag=1
forum=clean
check=1
endif
--- End code ---

Welcome again! :)

ckrum:
You are Genius!
Thank you very much.
I just found and bought the GLBasic today.
Thanks to you my program runs correctly.
It is a simulation of the lottery drawing to help the user generate a unique set of numbers.
It simulates an actual drawing by mixing virtual lottery balls rather than generating random numbers.
Not like that is going to help me win the lottery but the concept provided some enthusiasm on my part to fight the syntax.

Thank you again.

erico:
hehe nice idea! I did a random number generator a couple years ago on the purpose that my my machine+GLB would make it an easy win...well, I didn´t win, probably cause my machine was angry. ;/

You will see GLB is a fine tool, check the online manual or press F1 in program and you pretty much get all you need to start up good.
This forum is also gold stuffed with examples and solutions beyond belief. Some questions can be answered with a simple search.

Enjoy!

Ian Price:
You might want to look at the SWAP command for your bubble-sorting function.

Welcome BTW. :)

Navigation

[0] Message Index

[#] Next page

Go to full version