del
New Member
Posts: 12
|
Post by del on Apr 30, 2019 11:29:02 GMT -5
Maybe I'm having a senior moment (age 79), but I cannot get a simple gosub to work in a GUI.
I got a bit of non-GUI code that works OK but the code in a GUI does not.
I keep getting the error “Gosub Branch label [*****] not found!”
I've simplified my bit of error code for this forum.
'No problem with this Gosub Gosub [dateformat] Print,a$
End
[dateformat]
A=202
a$ = Str$(A)
Return
***********************************************************************
'Problem with this Gosub Branch label [dateformat] not found! Global a$ Nomainwin
Button #del.BEnd, "End",BEnd ,UL ,210 ,200 ,70 ,30
Button #del.BStart, "Start",BStart,UL,150 ,20 ,100 ,30
Statictext #del.lable1,"", 30,90, 40, 60
Open "Tester" for window as#del
#del "TrapClose BEnd"
Wait
Sub BStart handle$
Gosub [dateformat]
#del.lable1,a$
End Sub
[dateformat]
A=202
a$ = Str$(A)
Return
Sub BEnd handle$
close #del
End
End Sub
Can someone help please?
|
|
|
Post by metro on Apr 30, 2019 12:09:41 GMT -5
|
|
|
Post by Rod on Apr 30, 2019 12:35:52 GMT -5
Yes [labels] are local in scope. So you cant jump Subs with [labels] only within Subs. In a Sub you need to jump to another Sub
|
|
|
Post by Gordon Rahman on Apr 30, 2019 17:23:21 GMT -5
Hello Del, This is the hardest thing to explain to myself: GOSUB is a part of a listing and CALL SUB is calling a part of memory. Now this part of memory is managed seperatetly by the computer (LB) wereby the computer keeps track of the variables via a separate organisation (that it calls the local scoop). So it won't find a lable beyond it's scoop ... onless you could make that lable global.... So GOSUB I think is easy ... but Call Subs needs some Global, call by ref(erence), call by val(ue) I'll get senior moment soon too .... I'm slightly younger lol. Gordon Gordon
|
|
del
New Member
Posts: 12
|
Post by del on May 1, 2019 9:25:33 GMT -5
Thanks Guys, I do appreciate your guidance.
|
|