Author Topic: Small issue with counter made with shapesheet only.  (Read 309 times)

0 Members and 1 Guest are viewing this topic.

Gustavo

  • Jr. Member
  • **
  • Posts: 37
    • OperaGen
Small issue with counter made with shapesheet only.
« on: September 03, 2018, 12:16:23 AM »
Hi all people in the forum.

I did a counter in a shape's shapesheet using:
Code: [Select]
=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
Code: [Select]
=User.counter/41But, do you have had this behaviour in a shapesheet code based counter before? Do you know why is it caused?. I wonder. Best regards.
« Last Edit: September 03, 2018, 12:19:41 AM by Gustavo »

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1603
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Small issue with counter made with shapesheet only.
« Reply #1 on: September 03, 2018, 04:25:00 AM »
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

  • Hero Member
  • *****
  • Posts: 1138
Re: Small issue with counter made with shapesheet only.
« Reply #2 on: September 03, 2018, 11:29:25 AM »
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

  • Jr. Member
  • **
  • Posts: 37
    • OperaGen
Re: Small issue with counter made with shapesheet only.
« Reply #3 on: September 03, 2018, 03:05:04 PM »
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
Code: [Select]
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
Code: [Select]
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...
« Last Edit: September 04, 2018, 01:27:19 AM by Gustavo »