Basic pseudo object code no reachable when defined into a basic library...

classic Classic list List threaded Threaded
5 messages Options
Patrick Gelin Patrick Gelin
Reply | Threaded
Open this post in threaded view
|

Basic pseudo object code no reachable when defined into a basic library...

Hi,

I've got a problem with pseudo object no reachable when defined into
library. The error message when I call new is :

"This object is not accessible. Invalid object reference."

Beloww is the Modul Test into library LibApplication, to define a Test
object displaying a "Hello Box" dialog  when execute

REM  *****  BASIC  *****
Option Compatible
Option ClassModule

Option Explicit

Private _value As Integer
Private const _Msg = "Hello World"

' #PROCEDURE#
==================================================================
' Name...........: Class_Initialize
' Description ...:
' Parameters ....:
' Syntax ........: Class_Initialize
' Return values .:
' Modified.......:
' Remarks .......:
' Related .......:
' Link ..........:
' Example .......:
Private Sub Class_Initialize()
     _valute = 1
End Sub

' #PROCEDURE#
==================================================================
' Name...........: Class_Terminate
' Description ...:
' Parameters ....:
' Syntax ........: Class_Terminate
' Return values .:
' Modified.......:
' Remarks .......:
' Related .......:
' Link ..........:
' Example .......:
Private Sub Class_Terminate()
End Sub

Rem
***************************************************************************
Rem
Rem PROPRIETES
Rem
Rem
***************************************************************************

Rem
***************************************************************************
Rem
Rem METHODES PRIVEES
Rem
Rem
***************************************************************************

Rem
***************************************************************************
Rem
Rem METHODES PUBLIQUES
Rem
Rem
***************************************************************************
' #PROCEDURE#
==================================================================
' Name...........: Execute
' Description ...:
' Parameters ....:
' Syntax ........: Execute()
' Return values .:
' Modified.......:
' Remarks .......:
' Related .......:
' Link ..........:
' Example .......:
Public Sub Execute()
     MsgBox _Msg & " : " & _value
End Sub


Module to test into my main document :

Sub Test()
     If GlobalScope.BasicLibraries.hasByName("LibApplication") Then
         GlobalScope.BasicLibraries.loadLibrary("LibApplication")
     End If

if GlobalScope.BasicLibraries.isLibraryLoaded("LibApplication") Then
     Call Application.OpenConnection(ThisDatabaseDocument)
Else
     MsgBox("Librairie LibApplication non chargée !")
EndIf

Dim oTest As Object
Set oTest = new Test
oTest.execute()
Erase oTest
End Sub


Do you think it's not possible to use pseudo object code into library ?
Do you know an other way than libraries to create domains (there is no
folder to manage macros ...)


--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Jean-Francois Nifenecker Jean-Francois Nifenecker
Reply | Threaded
Open this post in threaded view
|

Re: Basic pseudo object code no reachable when defined into a basic library...

Hi Patrick,

typo spotted in the Initialize sub :

Private Sub Class_Initialize()
     _valute = 1
End Sub

instead of

Private Sub Class_Initialize()
     _value = 1
End Sub


Best,
--
Jean-Francois Nifenecker, Bordeaux

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
TomD TomD
Reply | Threaded
Open this post in threaded view
|

Re: Basic pseudo object code no reachable when defined into a basic library...

Hi :)
Oooo there's some value in a nice cuppa T.
Regards from
a Tom :)

On 20 July 2018 at 09:49, <[hidden email]> wrote:

> Hi Patrick,
>
> typo spotted in the Initialize sub :
>
> Private Sub Class_Initialize()
>      _valute = 1
> End Sub
>
> instead of
>
> Private Sub Class_Initialize()
>      _value = 1
> End Sub
>
>
> Best,
> --
> Jean-Francois Nifenecker, Bordeaux
>
> --
> To unsubscribe e-mail to: [hidden email]
> Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-
> unsubscribe/
> Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
> List archive: https://listarchives.libreoffice.org/global/users/
> Privacy Policy: https://www.documentfoundation.org/privacy
>

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Patrick Gelin Patrick Gelin
Reply | Threaded
Open this post in threaded view
|

Re: Basic pseudo object code no reachable when defined into a basic library...

In reply to this post by Jean-Francois Nifenecker
Hi,

Thanks-you Jean-Francois for your correction. But it's not enought, the
problem is still here ... I finded why : The new operator failed to load
pseudo object code into a library from a document's call. It's same
problem for GlobalScope library (inter-contener call) or Document
library (inner-contener call).

But I can replace it with a function factory stored into the library and
called from my document ... :

----------------------------------
REM Factory Modul into LibApplication
Option Explicit

Function FactoryTest As Object
     FactoryTest = new Test
End Function

----------------------------------
REM Unitary test into my document
Sub Test2()
     If not GlobalScope.BasicLibraries.hasByName("LibApplication") Then
         MsgBox("Librairie LibApplication non installée !")
         Exit Sub
     End If

     GlobalScope.BasicLibraries.loadLibrary("LibApplication")
     if not GlobalScope.BasicLibraries.isLibraryLoaded("LibApplication")
Then
         MsgBox("Librairie LibApplication non chargée !")
         Exit Sub
     EndIf

     Dim oTest As Object

     oTest = FactoryTest()
     oTest.execute()
     Erase oTest
End Sub

Note : The Erase function call look's to run perfectly ...

So I need to add a specific modul in pseudo object library with
factories ...

Patrick

Thank you for your help.
Patrick


--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Jean-Francois Nifenecker Jean-Francois Nifenecker
Reply | Threaded
Open this post in threaded view
|

Re: Basic pseudo object code no reachable when defined into a basic library...

Hello Patrick,

(response in English that transcripts my private email in French)

Le 20/07/2018 à 17:37, Patrick Gelin a écrit :
>
> Note : The Erase function call look's to run perfectly ...

Why don't you use the usual
Set MyObject = Nothing

This is just a question. I'm not sure about the actual difference
between both approaches.

>
> So I need to add a specific modul in pseudo object library with
> factories ...

Don't you think that having an object factory in each class module would
be easier to maintain? Or is this impractical?


Best regards,
--
Jean-Francois Nifenecker, Bordeaux


--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy