Author Topic: How to fire a formula, only once, for an event?  (Read 2767 times)

0 Members and 1 Guest are viewing this topic.

getwilde

  • Newbie
  • *
  • Posts: 3
How to fire a formula, only once, for an event?
« on: November 26, 2013, 01: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!

« Last Edit: November 26, 2013, 04:26:15 PM by getwilde »

getwilde

  • Newbie
  • *
  • Posts: 3
Re: How to fire a formula, only once, for an event?
« Reply #1 on: November 26, 2013, 03:51:31 PM »
If it helps, here is my sample drawing/shape.

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3858
  • Ideas Visio-lized into solutions
Re: How to fire a formula, only once, for an event?
« Reply #2 on: November 26, 2013, 04: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.
Visio 2019 Pro

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3858
  • Ideas Visio-lized into solutions
Re: How to fire a formula, only once, for an event?
« Reply #3 on: November 27, 2013, 10:48:44 AM »
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
Visio 2019 Pro

getwilde

  • Newbie
  • *
  • Posts: 3
Re: How to fire a formula, only once, for an event?
« Reply #4 on: December 02, 2013, 11:11:27 AM »
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?



« Last Edit: December 02, 2013, 07:33:27 PM by getwilde »