List Info

Thread: timing on loading libraries




timing on loading libraries
user name
2007-05-18 09:16:03
Hi,

In order to make sure that certain libraries are available,
one has to 
load them.
Since (to me) it is not clear what happens if a librabry is
already 
loaded (is a new reference made or not?) one can add a
check.

Now when more than one libraries are needed, one gets a
sequence as:

   If (Not
Globalscope.BasicLibraries.isLibraryLoaded("Tools"
)) Then
    
Globalscope.BasicLibraries.LoadLibrary("Tools")
   End If

   If (DialogLibraries.isLibraryLoaded("x")) Then
     DialogLibraries.LoadLibrary("x")
   End If
   oDlg = CreateUnoDialog(DialogLibraries.x.dlgx)

In my experience, this regularly leads to runtime errors on
the line 
with CreateUnoDialog.
I think that has to do with timing.
Error message (my translation:
	"Action not supported.
	Invalid call of procedure."

So my questions:
- Is it needed to do the load within a If-EndIf loop?
- If so, can timing be a problem and how to avoid it?

Thanks,
Cor

-- 

Cor Nouws
Arnhem - Netherlands
nl.OpenOffice.org - marketing contact

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: timing on loading libraries
user name
2007-05-18 13:19:20
Hi Cor,

Message de Cor Nouws  date 2007-05-18 16:16 :
> Since (to me) it is not clear what happens if a
librabry is already 
> loaded (is a new reference made or not?) one can add a
check.
> 
According to IDL description of
XLibraryContainer.loadLibrary it is 
useless to test if already loaded:
"Causes the accessed library to be loaded from its
storage if it hasn't 
already been loaded."

> Now when more than one libraries are needed, one gets a
sequence as:
> 
>   If (Not
Globalscope.BasicLibraries.isLibraryLoaded("Tools"
)) Then
>    
Globalscope.BasicLibraries.LoadLibrary("Tools")
>   End If
> 
>   If (DialogLibraries.isLibraryLoaded("x"))
Then
>     DialogLibraries.LoadLibrary("x")
>   End If
>   oDlg = CreateUnoDialog(DialogLibraries.x.dlgx)
> 
> In my experience, this regularly leads to runtime
errors on the line 
> with CreateUnoDialog.
> I think that has to do with timing.
> Error message (my translation:
>     "Action not supported.
>     Invalid call of procedure."
> 

Try to simply load the library and see if the problem
persists.
I have never experienced such error.
It may be due to the names of your dialog library and
module.
Personnally I prefer the getByName method:

DialogLibraries.LoadLibrary("x")
myLib = DialogLibraries.getByName("x")
myDialog = myLib.getByName("dlgx")
oDlg = CreateUnoDialog(myDialog)

______
Bernard

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: timing on loading libraries
user name
2007-05-18 16:24:30
Hi Bernard,

Bernard Marcelly wrote:

> According to IDL description of
XLibraryContainer.loadLibrary it is 
> useless to test if already loaded:
> "Causes the accessed library to be loaded from its
storage if it hasn't 
> already been loaded."

Simplifies a great deal. Thanks for that.

> Try to simply load the library and see if the problem
persists.
> I have never experienced such error.
> It may be due to the names of your dialog library and
module.

Indeed, the problem only exists if I call
'isLibraryLoaded'.

> Personnally I prefer the getByName method:
> 
> DialogLibraries.LoadLibrary("x")
> myLib = DialogLibraries.getByName("x")
> myDialog = myLib.getByName("dlgx")
> oDlg = CreateUnoDialog(myDialog)

Does that have a reason, that I might be able to understand
 ?

Regards,
Cor
-- 

Cor Nouws
Arnhem - Netherlands
nl.OpenOffice.org - marketing contact

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: timing on loading libraries
user name
2007-05-19 04:59:37
Message de Cor Nouws  date 2007-05-18 23:24 :
> Hi Bernard,

>> Personnally I prefer the getByName method:
>>
>> DialogLibraries.LoadLibrary("x")
>> myLib = DialogLibraries.getByName("x")
>> myDialog = myLib.getByName("dlgx")
>> oDlg = CreateUnoDialog(myDialog)
> 
> Does that have a reason, that I might be able to
understand  ?
> 

Of course I could have written a long instruction instead of
three:
oDlg =
CreateUnoDialog(DialogLibraries.getByName("x").get
ByName("dlgx"))

As you know, OOoBasic allows a shortcut for getByName
method:

myLib = DialogLibraries.getByName("x") ' strict
API usage
myLib = DialogLibraries.x    ' OOBasic shortcut

But this shortcut may conflict with an existing method name
for the 
object. As an example, have a spreadsheet with a sheet named
: tata
Here is the shortcut at work :

dim thisSheet as object
thisSheet = thisComponent.Sheets.tata
xray thisSheet

Now have another sheet named : Count
This time the shortcut will not work :

dim thisSheet as object
thisSheet = thisComponent.Sheets.Count
xray thisSheet

Because of potential name conflicts I think this OOoBasic
shortcut 
should not be used.

______
Bernard

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )