Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: vojo on February 08, 2019, 05:21:48 AM

Title: constraining shape data (prop.xx)
Post by: vojo on February 08, 2019, 05:21:48 AM
Is there a way to constrain shape data (prop.xxx)

Something like
- user enters a value (say 150 as a number)
- goal is to bound it (enforce a range....say max is 100....so 150 gets changed to 100 in prop.xxx.value cell)
   - later, a user could put in a new value...say 80...rules tested....80 in prop.xxx.value cell
- value placed in the prop.xxx cell

I tried a few things, but could get it to work
- setatref, setatrefexpr, setatrefval, etc
- bound in the format prop.xxx.format cell

I don't some sort of fixed list with 20 to 100 entries is reasonable (don't even know if Visio would explode)
I know I could use 2 props....input and resulting value...label appropriately...just seems a bit amateur.

No VBA, ideally

thoughts?
Title: Re: constraining shape data (prop.xx)
Post by: Yacine on February 08, 2019, 07:15:29 AM
is this too simple:
user.check = if(prop.xxx >100,setf(getref(prop.xxx),100),"")
?
... or:
user.check = setf(getref(prop.xxx), min(100, prop.xxx))
Title: Re: constraining shape data (prop.xx)
Post by: Croc on February 08, 2019, 07:49:57 AM
And why do not you like
prop.xx.Value = BOUND(,0,FALSE,-10000,100)
?
Title: Re: constraining shape data (prop.xx)
Post by: Yacine on February 08, 2019, 08:49:33 AM
Quote from: Croc on February 08, 2019, 07:49:57 AM
And why do not you like
prop.xx.Value = BOUND(,0,FALSE,-10000,100)
?
... brilliant!
Didn't know that you can use it with input fields.
Title: Re: constraining shape data (prop.xx)
Post by: vojo on February 08, 2019, 02:39:14 PM
Yacine...great, thanks...I guess I must have mistyped something...much appreciated

Title: Re: constraining shape data (prop.xx)
Post by: vojo on February 08, 2019, 02:40:15 PM
setf did give me "circular reference" error
Title: Re: constraining shape data (prop.xx)
Post by: wapperdude on February 08, 2019, 05:53:29 PM
Croc's solutions works fine and is simplist construct.

The setf formula won't work, it does give a circular argument.  Could use SETATREF with a placeholder.  But, you still need to define the limit test...well, you could wrap the Bound function around the SETATREFEXPR, but so much more complex.

For sake of completeness, here's formula to put into the prop Value cell:  =SETATREF(User.R1,SETATREFEVAL(BOUND(SETATREFEXPR("500"),0,FALSE,-1000,100))).   The value 500 gets assigned via the normal User Shape Data entry.  The value is passed to User.R1, then sent back to the Shape Data value cell.  No circular error.  This could be abbreviated to BOUND(SETATREFEXPR("500"),0,FALSE,-1000,100).  Which puts one step removed from Croc's original suggestion.