Exit scope
Exit scope
is it possible to add the possibility for early exiting a scope?
it would be very useful to me...
right now i have a macro that i dont want to turn into a function,
and it needs to be run several times... so theres no option for a goto
its the kind of macro that putting a do loop inside would make no sense
it would be very useful to me...
right now i have a macro that i dont want to turn into a function,
and it needs to be run several times... so theres no option for a goto
its the kind of macro that putting a do loop inside would make no sense
what?
i have a huge macro that i want to encapsulate in a scope
at some points inside that macro i want to Exit Scope
just like a Return in a function...
its code that would be a nightmare to turn into a function, and would reduce overall speed of code.. its not happening
its also the biggest bottleneck, so whatever i have to do, i will do it
exit scope would have been very useful, but i disabled some features and made it run by using a few extra if tests.. if i enable these features i NEED to be able to jump in the code, inside a macro..
come to think of it, it would be possible to:
#macro stuff(jumpto)
goto jumpto
#endmacro
right? thats one way i guess =)
i have a huge macro that i want to encapsulate in a scope
at some points inside that macro i want to Exit Scope
just like a Return in a function...
its code that would be a nightmare to turn into a function, and would reduce overall speed of code.. its not happening
its also the biggest bottleneck, so whatever i have to do, i will do it
exit scope would have been very useful, but i disabled some features and made it run by using a few extra if tests.. if i enable these features i NEED to be able to jump in the code, inside a macro..
come to think of it, it would be possible to:
#macro stuff(jumpto)
goto jumpto
#endmacro
right? thats one way i guess =)
You could use a Do ... Loop instead of Scope ... End Scope. Then you can use the Exit Do statement.
Code: Select all
Do
' Some code
If condition Then Exit Do
' Some more code
Exit Do
Loop
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
Re: Exit scope
You can have goto alright, if you give the macro a different label each callGonzo wrote:is it possible to add the possibility for early exiting a scope?
it would be very useful to me...
right now i have a macro that i dont want to turn into a function,
and it needs to be run several times... so theres no option for a goto
its the kind of macro that putting a do loop inside would make no sense
Code: Select all
#macro getmeout(label)
scope
k=k+1
dim as string dummy="Just passing through @ " & str(k+25)
for z as integer=1 to 50
if z=25+k then
print dummy
goto label
end if
next z
label
end scope
#endmacro
dim as integer k
getmeout(oot:)
getmeout(finish:)
getmeout(free:)
getmeout(thankyou:)
sleep
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
You could stop it looking like a loop by hiding the blocks in macros:
Either way it's nicer than any Goto-based solution, and it avoids having to invent multiple Goto labels.
Code: Select all
#define _scope do
#define end_scope loop while 0
_scope
'...
exit _scope
'...
end_scope
Re: Exit scope
bump
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Exit scope
Any questions ?agamemnus wrote:bump
I wonder me what dodicat posted at Sat Nov 19, 2011
Code: Select all
if z=25+k then
I did not that FreeBASIC evaluates an assignment in a if expression ?
Joshy
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
Re: Exit scope
It's an equality test. FB doesn't have '=='.D.J.Peters wrote:Looks as C/C++ code for me.Code: Select all
if z=25+k then
I did not that FreeBASIC evaluates an assignment in a if expression ?
Re: Exit scope
Any chance of this happening, or 0.