Small issue with counter made with shapesheet only.

Started by Gustavo, September 03, 2018, 05:16:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Gustavo

Hi all people in the forum.

I did a counter in a shape's shapesheet using:
=IF(User.time1<User.time2,0,SETF(GetRef(User.counter),GetVal(User.counter)+1)
and it worked fine, but the value in User.counter is always +41, so 0=41,1=82 and so on. This is not really a issue, 'cause I used in some other User cell an adjustment =User.counter/41
But, do you have had this behaviour in a shapesheet code based counter before? Do you know why is it caused?. I wonder. Best regards.

Visio Guy

Hi Gustavo,

Some things are tricky or impossible in the ShapeSheet. I wouldn't depend on that 41 working perfectly every time - makes me nervous.

I've tried to get self-examining things to work inside the ShapeSheet, for example: getting the font size to fit the text inside of the shape. I have been successful, but I always felt weird about the calculation running 41 times or so. :)

What exactly are you trying to accomplish? Maybe some of us will have ideas on a better way to do it!
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

vojo

I do this kind of thing all time.  Never use getval()

visio has this uncool trick of moving things around in its internal db when things change (shapes add/delete, cells added/deleted)
getval () looks up the instance regardless of where moved and gets the value of that cell.

in 20 years, I have NEVER seen this come into play in 1000s of drawings.  all are multi shape drawings and vast majority are multipage drawings.

you can emulate the desired behavior this by the following
user.test = if (user.time1<user.time2,false,true)
user.testtime = if(user.test = true, user.time +1,) + user.time = user.testime + dependson(user.test)

last term ensure user.testime is evaluated if user.test is evaluated.
Can omit middle terms if further debug needed

you sure nothing else is altering your user.time cell?????



Gustavo

#3
Hi VisioGuy and vojo, thank you for your insights and experience.

I'm building a small client-based line graphic, that is built by refreshing a single external data recordset with date and value from some sensor, so I built a small data "table" in a bunch of property cells (Prop.value1,Prop.value2,Prop.value3... etc.), and when the external record is refreshed in Visio, the shape does compare if the date (User.time1) of the refreshed external record is different/earlier than previous one (User.time2),and if so it updates the cell counter (User.counter), which triggers a dynamic formula to write in the corresponding Property cell.

As a matter of fact, I had it kinda built as vojo pointed out, but not "embedded" in the counter loop, but with an additional
IF(User.time1<User.time2,0,SETF(GetRef(User.counter),GetVal(User.counter)+1)+SETF(GetRef(Scratch.A3),NOT(Scratch.A3)) then the dynamic writing cell "catch" the binary change in Scratch.A3 in the form of
DEPENDSON(Scratch.A3)+SETF(GetRef(Scratch.D3),"SETF(GETREF(Prop.value"&User.counter&"),Prop._VisDM_externalrecordvalue)"
with the result I described earlier nonetheless. I must point out that vojo's way seems cleaner and I should try it (and I will). The 41 multiply value is independent of the computer capacity, as I've tested it in three different computers with different specs, and results are the same. I thought that maybe it has to do with the way Visio process first the different shapesheet sections, but I got the same result if I put the counter in a property, user or scratch cell.

I've observed  only once in like 30 try outs, when instead of the 41, visio write a 39 or something, but as I have a reset formula for the counter and values once the property cells available are full, it seems that -almost- didn't matter, cause it behave "normal" again once reseted. So it work. But it's a headscratcher...