On 04/05/2014 09:13 AM, Marion & Noel Lodge wrote:
Hi,
Sorry I've been slow to respond to all your posts. It has taken me a while
to sort out what I think is happening.
Many of us are very busy and totally understand when it takes time to
respond!
Fernand, thanks for your code suggestion. I pasted it into the start of my
macros and the Wait() statement worked perfectly. Then I incorporated it
into my Init macro and discovered that none of my Wait() statements
worked. The same applied to the AccName macro. I was really puzzled and
probably spent longer than I should have on the problem, but I felt I
really needed an answer. Finally, through much trial and error I found
which macros Wait() worked in and which it didn't. My testing was not
exhaustive, but it seems that Wait() doesn't work in any macro that is
called from one of the Form's events. When I got back to reading my
emails, I discovered that Andrew was predicting that this might be the
case!
So if you really wanted wait to work inside an event handler, you would
need to write your own and then simply perform a busy wait. Something
like this code that won't work as written (too lazy to look up syntax
and such)
tempLong = getSystemTicks()
StopWhen = tempLong + someDeltaValue
Do While StopWhen < getSystemTicks()
Do something to eat a bit of time
For i = 0 To 1000
For j = 0 To 1000
doubleTemp = i + j
Next
Next
End
Then it occurred to me that, rather than use separate text files for
printing out the Now() values, if I used just one file, it would give me
the order of processing, and the exact times would not be so important. So
I did that and also added System Ticks / 1000. The result was as follows -
I purposely suggested two different files because.... if things were not
serial, then you might have two places attempting to write to the same
file at the same time (concurrency problem). My concern was that:
1. Macro A updates the form and control returns to Macro A that
continues to run.
2. The form event is triggered calling Macro B before Macro A finishes.
So, if one macro updated a field on a form, which caused an event to be
triggered, then the triggered event might be running in a separate
thread (at the same time) as the macro that updated the field. In fact,
if this was not the case, then I expected that the behavior would always
be the same, and it sounded like the behavior was not always the same
for you.
Init 1. 05/04/2014 23:20:37 43421.801
Init 2. 05/04/2014 23:20:37 43421.801
Init 3. 05/04/2014 23:20:37 43421.817
Init 4. 05/04/2014 23:20:37 43421.833
Init 5. 05/04/2014 23:20:37 43421.848
Init 6. 05/04/2014 23:20:40 43424.36
Init 7. 05/04/2014 23:20:40 43424.375
Name 1. 05/04/2014 23:20:40 43424.625
Name 2. 05/04/2014 23:20:40 43424.625
Name 3. 05/04/2014 23:20:40 43424.625
This demonstrates that macro Init ran before macro Name.
>From this, and a number of other tests I ran, I believe that -
1. Macros are always processed serially on a first come first served basis.
2. If macro A calls macro B, then Macro A waits until macro B has
completed before the remaining code of macro A is processed.
These were the conclusions that I was hoping for. As well, I now have a
mechanism for checking out other timing situations where I'm not sure what
is going on.
So thank you all for your input - it has been an interesting journey!
Noel
--
Noel Lodge
lodgemn@gmail.com
PS Alex, Yes you are right - the account name needs to be fetched from
another table.
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info: http://www.pitonyak.org/oo.php
--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
Context
Re: [libreoffice-users] Do Macros run serially or in parallel? · Alex McMurchy
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.