Author Topic: Using dlls  (Read 8038 times)

roughbert

  • Guest
Using dlls
« on: August 06, 2008, 04:40:33 PM »
Thus spake the Users Guide:
Quote
You use/write a DECLARE SUB command if you developed an external module for ScriptBasic programs in C.
So if we have a dll and header using CDECL we can use it directly?

I'm thinking of the SQLite one in particular.

For example, if the header file contains:

Code: [Select]
int sqlite3_open(
  const char *filename,   /* Database filename (UTF-8) */
  sqlite3 **ppDb          /* OUT: SQLite db handle */
);

the first parameter is a pointer to a zero-terminated string and the second is a pointer to a 4-byte address containing a database handle.

What does our eqivalent Scriptbasic DECLARE statement look like?

Thanks,

Chris



Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: Using dlls
« Reply #1 on: August 06, 2008, 06:14:47 PM »
Chris,

Here is the mysql.bas include file which defines the mysql::xxx function calls.

Code: [Select]
module mysql

declare sub ::RealConnect alias "mys_real_connect" lib "mysql"
declare sub ::Connect alias "mys_config_connect" lib "mysql"
declare sub ::Close alias "mys_close" lib "mysql"
declare sub ::Query alias "mys_query" lib "mysql"
declare sub ::FetchArray alias "mys_fetcharray" lib "mysql"
declare sub ::FetchHash alias "mys_fetchhash" lib "mysql"
declare sub ::AffectedRows alias "mys_affected_rows" lib "mysql"
declare sub ::ChangeUser alias "mys_change_user" lib "mysql"
declare sub ::CharacterSetName alias "mys_character_set_name" lib "mysql"
declare sub ::DataSeek alias "mys_data_seek" lib "mysql"
declare sub ::ErrorMessage alias "mys_error" lib "mysql"
declare sub ::GetClientInfo alias "mys_get_client_info" lib "mysql"
declare sub ::GetHostInfo alias "mys_get_host_info" lib "mysql"
declare sub ::GetProtoInfo alias "mys_get_proto_info" lib "mysql"
declare sub ::GetServerInfo alias "mys_get_server_info" lib "mysql"
declare sub ::Info alias "mys_info" lib "mysql"
declare sub ::InsertId alias "mys_insert_id" lib "mysql"
declare sub ::Kill alias "mys_kill" lib "mysql"
declare sub ::Ping alias "mys_ping" lib "mysql"
declare sub ::EscapeString alias "mys_real_escape_string" lib "mysql"
declare sub ::SelectDatabase alias "mys_select_db" lib "mysql"
declare sub ::Shutdown alias "mys_shutdown" lib "mysql"
declare sub ::Stat alias "mys_stat" lib "mysql"
declare sub ::ThreadId alias "mys_thread_id" lib "mysql"

end module

Look at the interface.c for the mysql extension module to see the code behind these functions.

Peter Verhas created a 'do nothing' extension module interface (trial) as an example that he documented pretty well and should be a big help. The developer guide has a section on building extension modules as well.

Post your progress reports as this forum could use a little activity.  ;)


John
« Last Edit: August 06, 2008, 09:32:08 PM by support »