Show how to call a function in a shared library (without dynamically linking to it at compile-time). In particular, show how to call the shared library function if the library is available, otherwise use an internal equivalent function.

This is a special case of calling a foreign language function where the focus is close to the ABI level and not at the normal API level.



Related task

 OpenGL -- OpenGL is usually maintained as a shared library.


without js -- not from a browser, mate!
string {libname,funcname} = iff(platform()=WINDOWS?{"user32","CharLowerA"}:{"libc","tolower"})
atom lib = open_dll(libname)
integer func = define_c_func(lib,funcname,{C_INT},C_INT)
if func=-1 then
    ?{{lower('A')}} -- (you don't //have// to crash!)
else
    ?c_func(func,{'A'}) -- ('A'==65)
end if
