Real World API examples?
[1/2] from: depotcity::telus::net at: 5-May-2001 17:38
Hello again.
Just looking at the API .dll side of view/pro and was wondering if there are any "real
world" examples for Windows out there?
Terry Brownell
[2/2] from: larry:ecotope at: 5-May-2001 18:41
Hi Terry
Not sure if this is real world, but here is a script which shows how to
access the C-Runtime Library on Windows. This runtime library is crtdll.dll
in the Windows/System directory. You can view the functions available by
right-clicking on the DLL and choosing Quickview (if you have it installed).
For docs of args and return vals, check a C manual.
On my machine, the script produces these results:
C-Runtime DLL Results
Rebol log-e 5: 1.6094379124341
C log 5: 1.6094379124341
Rebol log-10 pi: 0.497149872694134
C log10 pi: 0.497149872694134
Rebol sine/radians pi / 4: 0.707106781186547
C sin pi / 4: 0.707106781186547
C floor 5.8: 5
C ceil 5.8: 6
C pow 2 3: 8
C toupper #"a": A
C clock function (ms) 1040
Cheers
-Larry
-------------code----------------------
REBOL [
Title: "Call C Library DLL"
Author: "Larry Palmiter"
Date: 19-May-2000
File: %clib.r
Purpose: {
Tests some Dll calls to Windows
C runtime library
}
]
clib: load/library %crtdll.dll
clock: make routine! [
return: [integer!]] clib "clock"
log: make routine! [arg [decimal!]
return: [decimal!]] clib "log"
log10: make routine! [arg [decimal!]
return: [decimal!]] clib "log10"
fabs: make routine! [arg [decimal!]
return: [decimal!]] clib "fabs"
ceil: make routine! [arg [decimal!]
return: [decimal!]] clib "ceil"
floor: make routine! [arg [decimal!]
return: [decimal!]] clib "floor"
sin: make routine! [arg [decimal!]
return: [decimal!]] clib "sin"
pow: make routine! [arg1 [decimal!] arg2 [decimal!]
return: [decimal!]] clib "pow"
toupper: make routine! [arg [char!]
return: [char!]] clib "toupper"
print [newline "C-Runtime DLL Results"]
print [newline "Rebol log-e 5: " log-e 5]
print ["C log 5: " log 5 newline]
print ["Rebol log-10 pi:" log-10 pi]
print ["C log10 pi: " log10 pi newline]
print ["Rebol sine/radians pi / 4:"
sine/radians pi / 4]
print ["C sin pi / 4: " sin pi / 4]
print [newline "C floor 5.8:" floor 5.8]
print [newline "C ceil 5.8: " ceil 5.8]
print [newline "C pow 2 3: " pow 2 3]
print [newline {C toupper #"a":} toupper #"a"]
print [newline "C clock function (ms)"
(a: clock wait 1 clock - a)]
free clib
halt
---------------end code--------------------------