Monday, December 19, 2011

[Lhogho] IsInetOffline? an example of Win32 API wrapping.

Lately I've been having a lot of fun getting my head around the Lhogho programming language. It's a compiled variant of Logo, running on Linux and Windows.

The following code demonstrates wrapping the Win32 API, in this case the IsInetOffline function in URL.DLL. The commented line is taken from a WIN32API.TXT file I found on the internet.

; Private Declare Function InetIsOffline Lib "url.dll" (ByVal dwflags As Long) As Long
make "url_handle libload "url.dll
to InetIsOffline? :dwflags end
external "InetIsOffline? [ U4 InetIsOffline U4] :url_handle

ifelse InetIsOffline? 0 <> 0
 [ print [internet offline] ]
 [ print [internet online] ]

I rather like the notation for defining the call to the DLL itself:
'external' <localsymbol> '[' <returntype> <dllsymbol> <arg1type> ... ']' <libloadvalue>


I've written a few bits and pieces of code which can be found over on the Lhogho forum. Enjoy!

No comments: