Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: getwilde on November 26, 2013, 06:26:54 PM

Title: How to fire a formula, only once, for an event?
Post by: getwilde on November 26, 2013, 06:26:54 PM
First off, hello everyone! Frequent lurker, recent member.  This site has been a great resource.

I'm hoping for some help, as I think I'm fundamentally misunderstanding something about Shapesheet formulas.

I've created a "Comment" shape.  (See attached screenshot.)  The entire shape can be moved (obviously), just the arrow pointer can be moved/glued (via startpoint), just the "comment box" can be moved (via endpoint), and the "comment box" can be widened (via handle). And the arrow can be manually swapped from left to right side and vice versa, either via the Shape Data panel or via right-click action menu.

What I'm struggling with is this:  When the user swaps the arrow left-to-right, I'd like for the comment "box" to appear to stay in place while only the arrow switches sides.  (I've attached an example.)  The way to do this is by setting EndX to EndX+Width (and/or EndX-Width), which works when I add this to the "Arrow on Left" Action.  But I'd like this same formula to run if the user swaps the arrow via Shape Data.  I've tried putting the formula in it's own Action with DependsOn but nothing happens.  I've tried putting the formula in a User-defined Cell, but it creates an infinite loop for reasons I don't understand.  I've tried putting it in Scratch as well.  Like I said, I think I'm missing some fundamental concept with shapesheet formulas.

So... first question is:  How do I accomplish the immediate task?
But more importantly, I'd like to understand where I put a formula that I want to occur occasionally, and how I get it to fire once without looping indefinitely?

Thank you in advance!

Title: Re: How to fire a formula, only once, for an event?
Post by: getwilde on November 26, 2013, 08:51:31 PM
If it helps, here is my sample drawing/shape.
Title: Re: How to fire a formula, only once, for an event?
Post by: wapperdude on November 26, 2013, 09:58:53 PM
The fundamental problem is that the box is "slaved" to the line shape.  It has to move.  To maintain the box position, the box must be the master and the line the slave.  Thus, the line begin point should be something like:  if "right side"=true, set line begin to rectangle shape width*1 otherwise, set it to rectangle shape width*0.  This moves the line's beginning x location to either the right or left side of the rectangle shape.

HTH
Wapperdude.
Title: Re: How to fire a formula, only once, for an event?
Post by: wapperdude on November 27, 2013, 03:48:44 PM
You might want to check out this post:  User-submitted Stuff / Rectangular Callout: smart and flexible!, http://visguy.com/vgforum/index.php?topic=1472.msg6242#msg6242.

Go to the last entry for the latest version.

HTH
Wapperdude
Title: Re: How to fire a formula, only once, for an event?
Post by: getwilde on December 02, 2013, 04:11:27 PM
Thanks for the response, WapperDude! I had created this shape as a one-dimensional line in order to get some of the "glue" benefits of a connector.  However, I'll take a good look at those custom call-out shapes you posted.

More generally, how do I call functions on certain events in shapesheets?  And any insights as to why DEPENDSON() seems to be ignored completely? What is causing the infinite loop?

UPDATE:  Cool shapes, WapperDude.  I'll base my solution on your examples.  I'd still like to understand the concepts I've asked about.  For example, I've found that I can place a common function in its own Action cell, then call EVALCELL() from another Action, which allows for some code reuse and  gets around one infinite loop issue.  But is there a way to evaluate that same Action cell when the user selects "Right" or "Left" from the Shape Data panel?