Re: [api-dev] disposing of macros

2005-11-15 Thread Andrew Douglas Pitonyak



Douglas Staas wrote:


i'm reposting this question:

What is meant by "provide for disposal when the document is closed"? Where 
could I find this in the documentation?
 

Well, where did you read this? It is not possible to answer without 
context. No wait, I just ran a GOOGLE search on the exact phrase and 
found this:


http://www.mail-archive.com/dev@api.openoffice.org/msg01793.html

Next time, quote enough of the message to provide context.

Here is the entire quote:

Sounds like everything is being loaded into memory and not being released when 
you close your original document. Does your on Open Event macro provide for 
disposal when the document is closed ?


One possible reading of this is that the open document has resources, 
such as graphics, or pointers, or some kind of internal structures. When 
the document is closed, Alex is wondering if all of the document's 
resources are released, deleted, freed, (no longer used). Kind of like 
what might happen if a program opened a file and then left the file 
opened. You could not create and use the file again, because it would 
already be listed as open.


I have no idea where this would be in the documentation, because it 
would depens on the type of resourced that might be causing the problem. 
One possibility might be that your macro uses a GLOBAL variable to hold 
a reference to a dialog. The document closes, but eh global variable 
still exists and can therefore not be referenced again. If this were the 
case, then loading the Basic IDE might cause these resources to be released.


This is, of course, all speculation on my part, espcially since I have 
not seen your macro.


--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] disposing of macros

2005-11-15 Thread Andrew Douglas Pitonyak
I was able to extract one attachement from this email, so I took a look 
at it. I noticed a few unusual things.


Consider the OK button. The OK Button is listed as type OK button, NOT 
as a default button. Because of this, when you click on the button, an 
event is automatically fired, that will CLOSE the dialog.


The button also has some events tied to things such as key press and 
mouse click. There are two issues with this. First, you should probably 
just use the "when initiating" event, which covers both of the cases. 
Second,  when you click on the button, it is supposed to do two distinct 
things. The OK action, because this is an OK button, and use your 
events. Which is done first? Which is done second? The primary problem 
here, is that the OK action changes the state of the dialog. If these 
fire in a multi-threaded way, I have no idea which will be finished 
first and what the result will be. It is likely to be timing related and 
unreliable. Off hand, I reccomend that you use one method or the other. 
In other words, either let the action close the dialog, or perform the 
actions AFTER the dialog has closed if OK was used to close the dialog. 
Using the methods that you  describe, are likely to leave things in an 
unfinished state.


Douglas Staas wrote:


i'm reposting this question:

What is meant by "provide for disposal when the document is closed"? Where 
could I find this in the documentation?





 



------------

Subject:
[api-dev] disposing of macros
From:
[EMAIL PROTECTED] (Douglas Staas)
Date:
Thu, 10 Nov 2005 20:34:16 +
To:
dev@api.openoffice.org

To:
dev@api.openoffice.org





Subject:
Re: [api-dev] macro doesn't run
From:
[EMAIL PROTECTED] (Douglas Staas)
Date:
Thu, 10 Nov 2005 19:16:52 +
To:
dev@api.openoffice.org

To:
dev@api.openoffice.org


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] disposing of macros

2005-11-16 Thread Douglas Staas
>The button also has some events tied to things such as key press and 
>mouse click. 
I have since changed this. I removed the event bindings and simply call the 
code like so:

If oDialog.Execute() = 1 Then
SetAllText()
End If

Also, you hit the nail on the head. My macro uses a GLOBAL variable to hold a 
reference to the dialog. What should I do to clean up when closing the 
document? Or is this situation to be avoided altogether?

thanks
doug


> 
> 
> Douglas Staas wrote:
> 
> >i'm reposting this question:
> >
> >What is meant by "provide for disposal when the document is closed"? Where 
> >could I find this in the documentation?
> >  
> >
> Well, where did you read this? It is not possible to answer without 
> context. No wait, I just ran a GOOGLE search on the exact phrase and 
> found this:
> 
> http://www.mail-archive.com/dev@api.openoffice.org/msg01793.html
> 
> Next time, quote enough of the message to provide context.
> 
> Here is the entire quote:
> 
> Sounds like everything is being loaded into memory and not being released 
> when 
> you close your original document. Does your on Open Event macro provide for 
> disposal when the document is closed ?
> 
> 
> One possible reading of this is that the open document has resources, 
> such as graphics, or pointers, or some kind of internal structures. When 
> the document is closed, Alex is wondering if all of the document's 
> resources are released, deleted, freed, (no longer used). Kind of like 
> what might happen if a program opened a file and then left the file 
> opened. You could not create and use the file again, because it would 
> already be listed as open.
> 
> I have no idea where this would be in the documentation, because it 
> would depens on the type of resourced that might be causing the problem. 
> One possibility might be that your macro uses a GLOBAL variable to hold 
> a reference to a dialog. The document closes, but eh global variable 
> still exists and can therefore not be referenced again. If this were the 
> case, then loading the Basic IDE might cause these resources to be released.
> 
> This is, of course, all speculation on my part, espcially since I have 
> not seen your macro.
> 
> -- 
> Andrew Pitonyak
> My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
> My Book: http://www.hentzenwerke.com/catalog/oome.htm
> Info:  http://www.pitonyak.org/oo.php
> See Also: http://documentation.openoffice.org/HOW_TO/index.html
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] disposing of macros

2005-11-16 Thread Andrew Douglas Pitonyak

Douglas Staas wrote:

The button also has some events tied to things such as key press and 
mouse click. 
   


I have since changed this. I removed the event bindings and simply call the 
code like so:

   If oDialog.Execute() = 1 Then
   SetAllText()
   End If

Also, you hit the nail on the head. My macro uses a GLOBAL variable to hold a 
reference to the dialog. What should I do to clean up when closing the 
document? Or is this situation to be avoided altogether?

thanks
doug
 

It looks like you are well on your way! There is a difference between 
GLOBAL, PRIVATE, and PUBLIC when they are placed at the module level.


If you ONLY need the variable to be visible in one module, then use 
PRIVATE. If you require it outside of the current module, then use 
PUBLIC. In general, you should only use GLOBAL if you want the variable 
to live for a long long long long time (I outline the differences in my 
book, but lack the desire to fully explain it here and now); an example 
would be for an event listener, which needs to hold its value between 
runs. Think of Global as similar to static.


I must be careful on my wording here...

You could perhaps explicitly set variables declared outside of a sub or 
function to be NULL after you use them.




 


Douglas Staas wrote:

   


i'm reposting this question:

What is meant by "provide for disposal when the document is closed"? Where 
could I find this in the documentation?



 

Well, where did you read this? It is not possible to answer without 
context. No wait, I just ran a GOOGLE search on the exact phrase and 
found this:


http://www.mail-archive.com/dev@api.openoffice.org/msg01793.html

Next time, quote enough of the message to provide context.

Here is the entire quote:

Sounds like everything is being loaded into memory and not being released when 
you close your original document. Does your on Open Event macro provide for 
disposal when the document is closed ?



One possible reading of this is that the open document has resources, 
such as graphics, or pointers, or some kind of internal structures. When 
the document is closed, Alex is wondering if all of the document's 
resources are released, deleted, freed, (no longer used). Kind of like 
what might happen if a program opened a file and then left the file 
opened. You could not create and use the file again, because it would 
already be listed as open.


I have no idea where this would be in the documentation, because it 
would depens on the type of resourced that might be causing the problem. 
One possibility might be that your macro uses a GLOBAL variable to hold 
a reference to a dialog. The document closes, but eh global variable 
still exists and can therefore not be referenced again. If this were the 
case, then loading the Basic IDE might cause these resources to be released.


This is, of course, all speculation on my part, espcially since I have 
not seen your macro.


--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index

 



--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]