Your Thoughts: Pros and Cons of using Programmable Attributes in Symbols (Hierarchical Block)

I’ve been working with creating Symbols (also Hierarchical Blocks) that use Programmable Attributes.

A GREAT set of features! Right?

For example, I can specify an Attribute as follows:
image

This declares the “Test” attribute as an int and with entry limits of 8 to 100 inclusive.
If I use the symbol and alter the “Test” attribute outside the limits, it warns me and prevents setting the new value outside the limits. Excellent … right? PRO

Here’s the CON:
I create a global parameter
.param Targ=10
I then try to set the “Test” attribute with “Targ”. I get the limit error message even if Targ is within the limits.
Here’s a simple .qsch illustrating both the PRO and CON.
Prog_attr_issue.qsch (572 Bytes)

To test the PRO, set “Test” to a value outside the limits. The Error is thrown and prevents you from setting a value outside the limit. This is expected.

To test the CON, set “Test” to “Targ”. The Error is thrown and prevents you from setting to a global parameter. This is because the error checking occurs at design-time.

The fix 1
By changing the Symbol Attribute definition to eliminate int[MIN:MAX], this prevents the design-time limit checking and allows me to place the param name “Targ” into “Test”.
However… if I want to perform limits testing, I need to do it inside the CBlock. For example here is a simple code snippet:

if((Test<8) || (Test>100)) Exit(“Test=%d. Limit exceeded\n”,Test);

This will flag the error exceeding the limit at run-time.

The fix 2
I can leave the design-time checking on the Symbol Attribute if I don’t use parameters in this field. If I want to use a global parameter in the Attribute, I can eliminate limit checking in the Symbol Attribute for that instance of the Symbol.

Any thoughts?
Any other PROs or CONs with Programming Attributes?

Hello lpoma

I think they are good for a finished product, if you want to prevent shooting feet all around but, not mandatory (depends on the “customer”). For testing/building, they are a limitation. “Choose your poison”.

Personally, I use them mixed: e.g. if I have a list of names then it makes more sense to use the programmable attributes that simplifies the typing process to a drop-down menu. If it’s values, I typically don’t use them (except, maybe, some boolean, like bool debug, less likely to be changed often).

Vlad

1 Like

@lpoma you can always override programable attribute by display the Raw Attributes, don’t have to go to symbol to modify that.

@KSKelvin ,

Yes. That is what I meant by: