Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: [books] Pre-release of Chapter 5 of Rebol - A programmer's guide

From: nick:guitarz at: 4-Jul-2008 11:34

Hmmm, I thought I posted that link several messages back... Anyway, here's how to wrap functions from a library (from the other link in that earlier message): ; to open the library: lib: load/library %TheNameOfYour.library ; to wrap a function in the library: your-rebol-function-name: make routine! [ return-value: [data-type!] first-parameter [data-type!] another-parameter [data-type!] more-parameters [and-their-data-types!] ... ] lib "TheFunctionNameInsideThelibrary" ; to run the wrapped function in Rebol with your parameters: your-rebol-function-name parameter1 parameter2 ... ; to free the library when done: free lib I'm not at all familiar with the MySQL api, but here's a quick example of the mysql_real_connect function wrapped for Rebol. You'll need to fix the datatypes (for example, I'm not sure what type mysql_init returns for use as the first parameter "conn"), but this outline should give you an idea of how to get started: lib: load/library %/usr/lib/libmysqlclient.so.15 mysql-connect: make routine! [ return: [integer!] parameter1 [int!] ; not sure of this type parameter2 [string!] parameter2 [string!] parameter2 [string!] parameter2 [string!] parameter2 [int!] parameter2 [string!] parameter2 [int!] ; not sure of this type ] lib "mysql_real_connect" ; the "conn" variable below is gotten by running mysql_init mysql-connect conn, "localhost" "root" "PASSWORD" "mysql" 0, "", 0 Quoting Tim Johnson <tim-johnsons-web.com>: