Graphics

 View Only
  • 1.  Simplified Chosen Item

    Posted 02-13-2023 12:24

    Hi everyone. Just posting a method I use that might help people simplify their Visual Logic.

    I've seen posted here, and I've seen in the Visual Logic files from previous users at my work, determining a menu selection using StringCompare and then multiply by 1, 2, 3, etc and add or determine max, but combine them then put into a selector.

    For long lists this is much less cumbersome.

    Simplifying determined text selected from a menu

    The diagram has 3 labeled portions that will be customized each time you make a switch-case scenario. The rest is fairly set in stone.

    Item 1 is a string that contains expected values. To keep things simple, values should be 10 characters or less. This string in this example is:

    Big4567890Medium7890Small67890Tiny567890
    

    The numbers are padding and are there as a confirmation of size. If each section is not 10 characters, the logic will fail. This is the string with the numbers replaced:

    Big_______Medium____Small_____Tiny______
    

    Item 2 is a link to a published text field. As you can guess, the user can only choose Big, Medium, Small, and Tiny.

    Item 3 is a set of values being put into the Input Selector. The user has 4 choices, so we have to have 4 results. From there the results can be piped into anything.

    the Math

    At the heart of this pseudo switch-case is String Position. By following a strict size rule on Item 1, the results from String Position can be distilled down to 0 through number of items - 1.

    When the comparison is done in String Position the reporting is off by one. The first position should be 0; this can be seen in Selectors used in Visual Logic. So the first thing to do is subtract 1 from the result. Next we divide by 10. Final results is 0,1,2, or 3 in this example.

    From the Divide block the results can be used as needed.

    The rule of 10 characters can be changed to any size, just match it with the divisor in the Division block.



    ------------------------------
    Azathoth
    Son of Cthulhu
    ------------------------------