Visio Guy

Visio Discussions => Programming & Code => Topic started by: DJHarris71 on September 20, 2021, 05:16:09 PM

Title: Why multiple calls when using RunMacro("xxx","xxx")+DependsOn(BegTrigger)
Post by: DJHarris71 on September 20, 2021, 05:16:09 PM
Hello,
I am trying to trigger a sub that only triggers when the BegTrigger becomes glued or unglued.
Unfortunately it triggers multiple times.

I have created this user cell: RunMacro("xxx","xxx")+DependsOn(BegTrigger).
I then debug.print a message.  The debugger prints the message twice - indicating it triggered twice.
Even more peculiar is that the sub is called when the Endpoint is moved (not the begin point).

How can I get this sub to trigger once, and only when the begin point is glued or unglued?

Thanks.
Title: Re: Why multiple calls when using RunMacro("xxx","xxx")+DependsOn(BegTrigger)
Post by: Surrogate on September 21, 2021, 08:58:18 AM
Quote from: DJHarris71 on September 20, 2021, 05:16:09 PM
I have created this user cell: RunMacro("xxx","xxx")+DependsOn(BegTrigger).
BegTrigger is depended for EventXFMod.
EventXFMod can triggered few times because changed X and Y coordinates, Lenght and so on.
EventXFMod Cell (Events Section) (https://docs.microsoft.com/en-us/office/client-developer/visio/eventxfmod-cell-events-section)
Title: Re: Why multiple calls when using RunMacro("xxx","xxx")+DependsOn(BegTrigger)
Post by: DJHarris71 on September 21, 2021, 12:15:28 PM
Any thoughts on this question?

"How can I get this sub to trigger once, and only when the begin point is glued or unglued?"


Title: Re: Why multiple calls when using RunMacro("xxx","xxx")+DependsOn(BegTrigger)
Post by: Surrogate on September 21, 2021, 12:43:21 PM
Quote from: DJHarris71 on September 21, 2021, 12:15:28 PM
Any thoughts on this question?
About month ago at Russian Visio forum we have question about EventXFMod.
You can look this discussion via Google Translate service (https://visio-getbb-ru.translate.goog/viewtopic.php?f=6&t=1714&_x_tr_sl=ru&_x_tr_tl=en&_x_tr_hl=ru&_x_tr_pto=nui,elem)
There is solution for EventXFMod. It works, but I didn't test it for BegTrigger.
Title: Re: Why multiple calls when using RunMacro("xxx","xxx")+DependsOn(BegTrigger)
Post by: Surrogate on September 21, 2021, 01:24:28 PM
Quote from: Surrogate on September 21, 2021, 12:43:21 PM
There is solution for EventXFMod. It works
Please check this attached file
Title: Re: Why multiple calls when using RunMacro("xxx","xxx")+DependsOn(BegTrigger)
Post by: DJHarris71 on September 21, 2021, 03:30:37 PM
Thanks for the Event Example.
I did this at first, but, by putting here, doesn't it fire for everything tied to the EventXFMod?  I only want it on BegTrigger?
Seems if I make it a User cell as I did (depending on BegTrigger Only), then I limit the amount of times this get fired.  Right?

Even with this, Occasionally I ran into infinite loops.  So to prevent this, I added a 'Global EventTime as Date' variable,
Then in my Sub that I call I added these two lines.  This seems to correct both issues: the multiple triggering and the infinite loop.
Although, this seems like a hack, it seems to do the trick.

If DateDiff("s", EventTime, Now) < 1 Then Exit Sub
EventTime = Now

Thanks for your feedback.  I am smarter now.
Title: Re: Why multiple calls when using RunMacro("xxx","xxx")+DependsOn(BegTrigger)
Post by: Surrogate on September 21, 2021, 03:54:48 PM
Quote from: DJHarris71 on September 21, 2021, 03:30:37 PM
I only want it on BegTrigger?
Seems if I make it a User cell as I did (depending on BegTrigger Only), then I limit the amount of times this get fired.  Right?
I modify my code for is started from User-defined cell. First time i also get infinite loop. But now it works. Try next edition in attachment