Well, I'm back again. Everything was going so smoothly as I added features to my plotting routine. After the last addition (which ran fine in the IDE) I tried to compile but got the following error message:
Error CS0159...No such label within the scope of the goto statement. However, the label is there as indicated in the following code of mine. I really need to move past this so hope someone can figure out what is wrong. Thanks, guys.
I know the code is not very elegant but it works. There is a form with several checkboxes that are then activated according to this code. As I stated before, all is well when run within the IDE. I read the docs on the goto statement but really didn't understand what it was telling me about the scope equal or wider than the calling goto.
Although you can use Goto to jump between different subs it may cause unpredictable errors because the local variables will still be the variables of the previous sub.
Goto is best used to jump inside a sub.
The optimized compiler doesn't allow jumps between different subs, and the target label must be in a scope equal or wider to the calling Goto.
The jumping is done within the same sub.
Thanks for all the previous help and am hoping this is solvable.
Jim Schuchert
Error CS0159...No such label within the scope of the goto statement. However, the label is there as indicated in the following code of mine. I really need to move past this so hope someone can figure out what is wrong. Thanks, guys.
B4X:
Sub frmplotpoints_mousedown(j,k)
j=upltx+(j/screenw)*(lwrtx-upltx)
j=Format(j,sdecpl)
k=uplty-(k/screenh)*(uplty-lwrty)
k=Format(k,sdecpl)
If chktraverse.Checked =True Then
txtpointid.Visible =True
Goto traversehere '[color=red]where the error occurs while compiling[/color]
End If
'txtpointid.Visible =True
txtpointid.Text =k & " " & j
FileOpen(c,strfilename,cRead)
lineoftext=FileRead(c)
Do Until lineoftext=EOF
coord()=StrSplit(lineoftext,",")
If j >=coord(2)-5 AND j<=coord(2)+5 AND k>=coord(1)-5 AND k<=coord(1)+5 Then
pt=coord(0)
If intcounter=0 OR intcounter="" Then
invpoint1=pt
'areapt1=pt
End If
If intcounter>0 Then
invpoint2=pt
areapt2=pt
End If
j=coord(2)
k=coord(1)
intcounter=intcounter+1
If chkpointid.Checked = True Then
txtpointid.Visible =True
txtpointid.text="Pt " & coord(0) & " N " & k & " E " & j
Goto endthisplot
'End If
End If
If chkinverse.Checked =True Then
'If intcounter>0 Then
strbearing=invpoint1 & "*" & invpoint2
startinverse8
continueinverse
converttodms
txtpointid.Visible =True
txtpointid.Text = strNS & strdeg & Chr(176) & strmin & Chr(39) & strsec & Chr(34) _
& strEW & " " & Format(dbldistance,sdecpl)
invpoint1=invpoint2 'so inverses can continue between points
Goto endthisplot
End If
'End If
If chkplotarea.Checked =True Then
If areapt1=pt Then
dblnorth=coord(1)
dbleast=coord(2)
End If
If areapt2=pt Then
dblnortha=coord(1)
dbleasta=coord(2)
End If
Areasqft = Areasqft + (dblNorth * dbleasta - dblnortha * dblEast)
dblnorth=dblnortha
dbleast=dbleasta
Areasqft = Areasqft + (dblnorth * dbleasta - dblnortha * dbleast)
txtpointid.Visible =True
txtpointid.Text ="Area = " & Format(areasqft/2,sdecpl) & " sq.ft."
'End If
Goto endthisplot
End If
traversehere: [color=red]this is the label. Error message said no such [/color]
'''If chktraverse.Checked =True Then
btntravplot.Visible =True
txtpointid.Visible =True
dblnorth=k
dbleast=j
dblnorth1=k
dbleast1=j
Goto endthisplot
'''End If
End If [color=red]this finishes other code above [/color]
lineoftext=FileRead(c)
Loop
endthisplot:
FileClose(c)
End Sub
I know the code is not very elegant but it works. There is a form with several checkboxes that are then activated according to this code. As I stated before, all is well when run within the IDE. I read the docs on the goto statement but really didn't understand what it was telling me about the scope equal or wider than the calling goto.
Although you can use Goto to jump between different subs it may cause unpredictable errors because the local variables will still be the variables of the previous sub.
Goto is best used to jump inside a sub.
The optimized compiler doesn't allow jumps between different subs, and the target label must be in a scope equal or wider to the calling Goto.
The jumping is done within the same sub.
Thanks for all the previous help and am hoping this is solvable.
Jim Schuchert