I've removed the restriction on Declarations being only Global and the code below tests this with early and late binding API call to MessageBox.

The exercise is a bit academic here but should be useful later in COM programming.

Oxygen Update http://community.thinbasic.com/index.php?topic=2517

[code=thinbasic]
uses "oxygen"
dim src as string

'--------------------
'LOCAL DECLARATIONS +
'early & late binding
'====================

src ="
#basic

'--------------
function test()
'==============

'LOCAL EARLY BINDING
'-------------------
declare function MessageBox lib `user32.dll` alias `MessageBoxA` (byval as long,
byval as string, byval as string, byval as long) as long
MessageBox 0,`Early binding okay`,`test local declaration`,0


'LOCAL LATE BINDING
'------------------
dim a=loadlibrary `user32.dll`
dim p=getProcAddress (a,`MessageBoxA`)

'LOW LEVEL TEST
'--------------
call p 0,`Late binding okay`,`test low level call`,0
'
'HIGH LEVEL TEST
'----------------
declare function MessageBox (byval as long, byval as string,
byval as string, byval as long) as long at p

MessageBox 0,`Late binding okay`,`test local declaration`,0

FreeLibrary a


end function

test

'THIS IS OUT OF SCOPE BECAUSE THE DECLARATION WAS LOCAL
'MessageBox 0,`okay`,`test inner declaration`,0

terminate
"


'msgbox 0,o2_prep src
o2_basic src
if len(o2_error) then
msgbox 0, o2_error : stop
end if
o2_exec


[/code]