Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.scripting.vbscript > #11439

Re: SQLite with VBScript UDF?

Newsgroups microsoft.public.scripting.vbscript
Date 2016-11-28 07:39 -0800
References (13 earlier) <9fa57da5-d983-4fdc-85a4-e1de4c8a6dfc@googlegroups.com> <o12q4o$rqo$1@dont-email.me> <7e8728c8-fc98-4798-8b0f-0dce39a1900b@googlegroups.com> <o1c5r2$pm2$1@dont-email.me> <d3e794d4-688e-4305-836d-e7b5130525b6@googlegroups.com>
Message-ID <3409b47b-5095-446e-a7d8-069a8f46744f@googlegroups.com> (permalink)
Subject Re: SQLite with VBScript UDF?
From bart.smissaert@gmail.com

Show all headers | View raw


Not tried it yet, but I think I should be able to make this work by keeping
a generic procedure in a normal module (not a class module) and pass the address
of that generic procedure (with AddressOf) to sqlite3_create_function_v2. Then delegate from there to the scripting code.
As you say I will need the 5th arg of sqlite3_create_function_v2, *pApp, which can be used as in the SQLite documentation:

The fifth parameter is an arbitrary pointer. The implementation of the function can gain access to this pointer using sqlite3_user_data().

I don't think I need IFunction, but will try it all out tonight.

RBS


On Sunday, 27 November 2016 21:00:04 UTC, bart.sm...@gmail.com  wrote:
> This looks all very neat, nice work!
> 
> It needs this adding to the form code to avoid problems when closing the form:
> 
> Private Sub Form_Terminate()
>     New_c.CleanupRichClientDll
> End Sub
> 
> Just thinking now if I could make this work with my own SQLite wrapper.
> Not sure, but it looks it could work.
> My script code will of course be different and not sure now about IFunction.
> I suppose this class interacts with SQLite?
> 
> RBS
> 
> 
> 
> On Saturday, 26 November 2016 14:23:45 UTC, Schmidt  wrote:
> > Am 23.11.2016 um 02:42 schrieb bart.smissaert@gmail.com:
> > 
> > > My VB6 dll can otherwise handle 64 bit Excel provided it is loaded by a VB6 COM exe.
> > > Doesn't look this VBScript idea is feasible then.
> > 
> > If you host that Script within the 32Bit-environment (your VB6-Dll),
> > then it is possible to delegate an SQLite-UDF-callback into it.
> > 
> > Below comes an example, which is using the vbRichClient5's built-in
> > ActiveScripting-Support, to show that such a thing will work:
> > (this is a VB6-Demo though, which requires a registered
> > vbRichClient5-package, downloadable from http://vbRichClient.com)
> > 
> > http://vbRichClient.com/Downloads/ScriptUDFs.zip
> > 
> > Here's a ScreenShot of the above Demo-App:
> > http://vbRichClient.com/Downloads/ScriptUDFs.png
> > 
> > For the Scripters here, who are interested in "what's going on
> > under the covers"...
> > 
> > The vbRichClient5 is a COM-lib, which has a built-in SQLite-wrapper,
> > so it's easy to address and use also from VBScript (per passed Objects)
> > 
> > And to delegate SQLite-CallBacks to VBScript-Functions, one needs
> > to define the Callback-Proc in a *generic* manner elsewhere first
> > (I did it per VB6 in vbRichClient5).
> > 
> > Generically defined means, that there needs to be a Helper-Object,
> > which wraps the needed SQLite-APIs for UDF-Handling - and then
> > this Helper-instance gets passed to VBScript, to implement and
> > handle the "UDF-matters for the concrete Function in question".
> > 
> > In the above (zipped) Demo, one of the Script-Functions is defined as:
> > 
> > Sub AddSomethingTo(ByVal ParamCount, ByVal UDF)
> >    If ParamCount = 2 Then 'the "normal case"
> >      UDF.SetResultDouble UDF.GetDouble(1) + UDF.GetDouble(2) 
> > 'parameter-indices are one-based
> >    Else 'an example, how to raise an error, if something cannot be 
> > handled by your function
> >      UDF.SetResultError "AddSomething: we need two parameters!"
> >    End If
> > End Sub
> > 
> > In fact, any VBScript-handled SQLite-UDF will have (aside from the name)
> > always the same Function-Signature with only the shown two Arguments:
> > - ParamCount (that's how many the User passed into the SQL-Function)
> > - UDF (here, a vbRichClient5-defined Helper-Class of type cUDF)
> > 
> > Since you are using the RC5 in your solution already, adapting it
> > to something similar in your own solution should be relatively easy.
> > 
> > HTH
> > 
> > Olaf

Back to microsoft.public.scripting.vbscript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-21 02:04 -0800
  Re: SQLite with VBScript UDF? JJ <jj4public@vfemail.net> - 2016-11-21 23:17 +0700
    Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-21 09:14 -0800
  Re: SQLite with VBScript UDF? GS <gs@v.invalid> - 2016-11-21 15:21 -0500
    Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-21 13:03 -0800
      Re: SQLite with VBScript UDF? GS <gs@v.invalid> - 2016-11-21 16:11 -0500
        Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-21 13:19 -0800
          Re: SQLite with VBScript UDF? GS <gs@v.invalid> - 2016-11-21 16:31 -0500
            Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-21 13:40 -0800
              Re: SQLite with VBScript UDF? GS <gs@v.invalid> - 2016-11-22 12:30 -0500
                Re: SQLite with VBScript UDF? GS <gs@v.invalid> - 2016-11-22 12:43 -0500
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-22 11:02 -0800
                Re: SQLite with VBScript UDF? GS <gs@v.invalid> - 2016-11-22 14:19 -0500
                Re: SQLite with VBScript UDF? "Mayayana" <mayayana@invalid.nospam> - 2016-11-22 15:27 -0500
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-22 14:12 -0800
                Re: SQLite with VBScript UDF? "Mayayana" <mayayana@invalid.nospam> - 2016-11-22 17:34 -0500
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-22 15:22 -0800
                Re: SQLite with VBScript UDF? "Mayayana" <mayayana@invalid.nospam> - 2016-11-22 20:06 -0500
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-22 17:42 -0800
                Re: SQLite with VBScript UDF? Schmidt <ng@vbRichClient.com> - 2016-11-26 15:23 +0100
                Re: SQLite with VBScript UDF? GS <gs@v.invalid> - 2016-11-26 15:21 -0500
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-27 08:11 -0800
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-27 12:59 -0800
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-28 07:39 -0800
                Re: SQLite with VBScript UDF? Schmidt <ng@vbRichClient.com> - 2016-11-28 18:28 +0100
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-29 05:59 -0800
                Re: SQLite with VBScript UDF? Schmidt <ng@vbRichClient.com> - 2016-11-29 22:01 +0100
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-29 13:35 -0800
                Re: SQLite with VBScript UDF? Schmidt <ng@vbRichClient.com> - 2016-11-30 06:31 +0100
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-29 13:01 -0800
                Re: SQLite with VBScript UDF? Schmidt <ng@vbRichClient.com> - 2016-11-30 06:51 +0100
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-30 00:17 -0800
                Re: SQLite with VBScript UDF? Schmidt <ng@vbRichClient.com> - 2016-11-30 10:50 +0100
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-11-30 02:45 -0800
                Re: SQLite with VBScript UDF? bart.smissaert@gmail.com - 2016-12-01 02:40 -0800

csiph-web