General area when it fits no where else

Moderator: Mmiscool

User avatar
By Ecoli-557
#51718 OK guys, I am still trying to learn this interpreter and I am still not getting the basics which is frustrating cuz I have been coding for a LONG time - just in another basic which was compiled (Picbasic Pro).
I am having trouble with the following code. It errors saying:
Else Without IF line 65535
End if Without IF line 97
Else Without IF line 65535
End if Without IF line 102
Else Without IF line 65535
End if Without IF line 107
End if Without IF line 112
If Without Endif line 117 0
And the code section is below:
Code: Select all[Menu.Up]
if io(laststat,UP) = 0 then
        Selected = Selected + 1
       if Selected = 4 then Selected = 0
        If Selected = 0 then
            rad1sel = 1
        else
            rad1sel = 0
        endif
        If Selected = 1 then
            rad2sel = 1
        else
            rad2sel = 0
        endif'Line 97
        If Selected = 2 then
            rad3sel = 1
        else
            rad3sel = 0
        endif'Line 102
        If Selected = 3 then
            rad4sel = 1
        else
            rad4sel =  0
        endif'Line 107
        rad1 = tft.obj.radio(" Option One", 10,180,20,rad1sel,2,tft.rgb(255,0,0))      'Example of a radio button
        rad2 = tft.obj.radio(" Option Two", 10,210,20,rad2sel,2,tft.rgb(255,0,0))      'Example of a radio button
        rad3 = tft.obj.radio(" Option Three", 10,240,20,rad3sel,2,tft.rgb(255,0,0))      'Example of a radio button
        rad4 = tft.obj.radio(" Option Four", 10,270,20,rad4sel,2,tft.rgb(255,0,0))      'Example of a radio button
endif'Line 112
wait'don't know why I need these but it works
return

I am just trying to move a selection from several (4) radio buttons.
If you push UP button it will cycle through the radio buttons and should show that the one you are currently on is selected by having its center filled in.

I don't see where I have failed to end an IF statement with an ENDIF except for:
if Selected = 4 then Selected = 0
which should be legal - shouldn't it???
User avatar
By forlotto
#51731 not endif as in other programming

Instead it is end if

important to have the space hope this helps?
User avatar
By Ecoli-557
#51733 I will try that. If thats the case, amazing how we 'think' we see what we see.
- and humbling.....
I will report later.
Regards.
User avatar
By Ecoli-557
#51734 Forlotto-
Thanks for the tip.
It pointed me closer, now I just have one error WHEN I press the UP button:
Syntax error in if command
Halted at line 85
0 winsock Disconnected!
I have capitalized the 1st letter in every IF-Then-Else-End If statement. Not so clear in the docs in fact its shows 2 different ways:
If bla = 5 then
Print “Bla is 5”
Else
Print “bla is not 5”
End if
The if can be nested as below :
if a > b then
print "a > b"
if b >c then
print "b > c"
else
print "b < c"
end if
else
print "a < b"
end if
The 1st shows a cap for the 'If' and the 'Else' and the 'End if' statements, but the 2nd has nothing capitalized at all....... confusing for a newbie to this realm.
I know it is new and in its infancy but I want to learn.

My code as it now stands with the single error is below:
Code: Select all[Menu.Up]
If io(laststat,UP) = 0 Then
        Selected = Selected + 1
    If Selected = 4 Then Selected = 0
        If Selected = 0 Then
            rad1sel = 1
        Else
            rad1sel = 0
        End If
        If Selected = 1 Then
            rad2sel = 1
        Else
            rad2sel = 0
        End If
        If Selected = 2 Then
            rad3sel = 1
        Else
            rad3sel = 0
        End If
        If Selected = 3 Then
            rad4sel = 1
        Else
            rad4sel =  0
        End If
        rad1 = tft.obj.radio(" Option One", 10,180,20,rad1sel,2,tft.rgb(255,0,0))      'Example of a radio button
        rad2 = tft.obj.radio(" Option Two", 10,210,20,rad2sel,2,tft.rgb(255,0,0))      'Example of a radio button
        rad3 = tft.obj.radio(" Option Three", 10,240,20,rad3sel,2,tft.rgb(255,0,0))      'Example of a radio button
        rad4 = tft.obj.radio(" Option Four", 10,270,20,rad4sel,2,tft.rgb(255,0,0))      'Example of a radio button
End if
wait'don't know why I need these but it works
return

What am I missing?