Very fast classic BASIC construct.
I will put this macro into the OxygenBasic core language
def on
======
'%1' name of index variale
'%2' goto or gosub or call
'%3' { @label1,@lael2,...}
'$$ reserved name ending
scope
static sys st$$[64]
if not st$$[1]
st$$[1]={%3}
endif
if %1
%2 st$$[%1]
endif
end scope
end def
function f(int v,n=0) as int
============================
'
on n gosub {@sr1,@sr2,@sr3,@sr4}
'
subroutine sr1
--------------
print "sr1"
end subroutine
'
subroutine sr2
--------------
print "sr2"
end subroutine
'
subroutine sr3
--------------
print "sr3"
end subroutine
'
subroutine sr4
--------------
print "sr4"
end subroutine
'
return v
end function
'
'TEST:
int i
for i=1 to 4
f(0,i)
next