Need to shorten an "Action" formula

Started by shockeymoe, February 13, 2015, 07:47:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

shockeymoe

I have a formula that I am using in an action that does exactly what I want except for one problem... It is too long!
When I shorten it somewhat it works but then it is incomplete.
Below is the formula. I have added line breaks to show it more clearly.

=SETF(GetRef(Layers.Visible[2]),1)+
SETF(GetRef(Layers.Visible[4]),0)+
SETF(GetRef(Layers.Visible[5]),0)+
SETF(GetRef(Layers.Visible[6]),0)+
SETF(GetRef(Layers.Visible[7]),0)+
SETF(GetRef(Layers.Visible[8]),0)+
SETF(GetRef(Layers.Visible[9]),0)+
SETF(GetRef(Layers.Visible[10]),0)+
SETF(GetRef(Layers.Visible[11]),0)+
SETF(GetRef(Actions.ToggleA1.Checked),0)+
SETF(GetRef(Actions.ToggleA2.Checked),0)+
SETF(GetRef(Actions.ToggleA3.Checked),0)+
SETF(GetRef(Actions.ToggleA4.Checked),0)+
SETF(GetRef(Actions.ToggleA5.Checked),0)+
SETF(GetRef(Actions.ToggleA6.Checked),0)+
SETF(GetRef(Actions.ToggleA7.Checked),0)+
SETF(GetRef(Actions.ToggleA8.Checked),0)+
SETF(GetRef(Actions.Full_Workflow.Checked),1)

The full formula works but ONLY if I click into any cell in the shapesheet, then it updates. Clicking into the shapesheet to invoke the formula is not a reasonable workaround.
Any ideas would be appreciated. The formula allows me to show or hide layers in order to show different pathways through a workflow.
Thanks

wapperdude

#1
A safe, easy way is remove the first part of the formula which assigns the desired value to the layer visibility and only retains the setting of the actions.checked.  So, the 2nd row in the actions section, which I defined as actions.LyrB has the resulting formula:  =SETF(GetRef(Actions.LyrA.Checked),FALSE)+SETF(GetRef(Actions.LyrB.Checked),TRUE)+SETF(GetRef(Actions.LyrC.Checked),FALSE)+SETF(GetRef(Actions.LyrAll.Checked),FALSE)

Then, add the user defined section and enter as many rows as there are layers.  Each row will have a formula that sets its associated layer visibility.  For example, in the 2nd user row, name it, user.LyrB, enter the formula:  =IF(OR(Actions.LyrB.Checked,Actions.LyrAll.Checked),SETF(GetRef(Layers.Visible[2]),TRUE),SETF(GetRef(Layers.Visible[2]),FALSE)).  Do the same for each row, referring to the appropriate actions row.  (Obviously, you will use your naming convention, not mine.)

Splitting the formula ought to solve your length problem.

Wapperdude
Visio 2019 Pro

shockeymoe

Thanks wapperdude for the prompt reply... sorry for the slow response.
This worked like a charm! The only difference I made is I removed the OR section because I assumed your assumption was that my last layer was a "show all" type of thing but it is in fact a separate layer on its own.
Bravo and thanks

wapperdude

Actually, I assumed that the "LyrAll" was a separate layer.  By using the "OR", it saved one row in the User Section, namely, a row for the "LyrAll", since it is included with each of the individual layer tests.  But, either way works.

Glad to hear the suggestion helped resolving your problem. 

Happy Visio-ing!
Wapperdude
Visio 2019 Pro