RosettaCodeData/Task/Call-a-function-in-a-shared-library/Phix/call-a-function-in-a-shared-library.phix
2026-02-01 16:33:20 -08:00

9 lines
355 B
Text

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,false)
if func=-1 then
?{{lower('A')}} -- (you don't //have// to crash! ^^^^^)
else
?c_func(func,{'A'}) -- ('A'==65)
end if