OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Declare DLL does not work in a different module

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Guillaume Audirac
Newbie
Newbie


Joined: 21 Feb 2005
Posts: 4

PostPosted: Tue Feb 22, 2005 6:25 am    Post subject: Declare DLL does not work in a different module Reply with quote

Hello,

Here is my piece of program :

Option Explicit
Declare Function VeeInitDll Lib "VeeGenApi.dll" () As Integer
Sub Main
Call VeeInitDll()
End Sub

It works well in this case.
Then, because I have to declare several long functions of my DLL, I separate the Declare and the Main program in 2 different modules :

Module1:
Option Explicit
Declare Function VeeInitDll Lib "VeeGenApi.dll" () As Integer

Module2:
Option Explicit
Sub Main
Call VeeInitDll()
End Sub

Then I run Main in Module2, with the error message "Undefined variable" at the "Call VeeInitDll()" line.
What does this mean ? Is there really an error or is it a bug ?

Thanks a lot for your help !
Guillaume Audirac
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Tue Feb 22, 2005 9:19 am    Post subject: Reply with quote

In principle, your approach should work. I have the DECLARE statement in the OO standard Library, and can call it from any Module I want (OO1.1.3)

Maybe the syntax checking is more strict with DECLARE functions ? Did you try

Code:
Dim u as long
u = VeeInitDll()
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Tue Feb 22, 2005 9:28 am    Post subject: Reply with quote

Oops, I have to correct myself. Just looked again into the code - I have written wrapper functions around the DECLARED functions to be able to call them from other modules. So it seems to be a bug (or a safety feature Smile ? )
Back to top
View user's profile Send private message
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Tue Feb 22, 2005 10:15 am    Post subject: Reply with quote

The reason for this error has already been described here:
http://www.oooforum.org/forum/viewtopic.phtml?t=17317&highlight=

Christian
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
Guillaume Audirac
Newbie
Newbie


Joined: 21 Feb 2005
Posts: 4

PostPosted: Tue Feb 22, 2005 11:38 pm    Post subject: Reply with quote

The link you propose is not related to the same problem.
And I agree with the post before : to make it working properly, I need to wrap my Declare function with another function in the same Module. Then the new name can be called in any module. Strange, isn't it ?

New version which works :

Module1:
Option Explicit
Declare Function VeeInitDll Lib "VeeGenApi.dll" () As Integer
Function oo_VeeInitDll() As Integer
oo_VeeInitDll = VeeInitDll()
End Function

Module2:
Option Explicit
Sub Main
Call oo_VeeInitDll()
End Sub


So, is it a bug or intentional ?
Guillaume Audirac
Back to top
View user's profile Send private message
hector
General User
General User


Joined: 11 Apr 2004
Posts: 6
Location: France

PostPosted: Thu Aug 27, 2009 3:36 pm    Post subject: Reply with quote

I would rather say it is a bug, and it seems to be still present in openoffice 3.1 ...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group