2014-11-05 16:54发布
This tab provides for more advanced modification, allowing you to apply a specific expression to the selected string objects. The expression can include any built-in arithmetic operators and functions that apply to strings (found in Pascal). Once again, if you wish to use the current value for the attribute as part of the expression, you will need to make reference to this original value, either by using the full name of the attribute, or by using the exclamation character (the supported substitute for the name of the attribute currently being modified). When using attribute names, if any names contain spaces, these must be replaced by the underscore character. So, for example, use of the Component Comment field within a formula should be entered as Component_Comment.
Consider for example three selected memory components specified in a design, with designators U1, U3 and U5. You might want to extend the designators of these components by including some indication of their role. Using the addition operator, you could write an expression to add to the existing string value of theName attribute. This would take the existing (original) string value and concatenate it with a specified new string, as illustrated below:
Name + \\\'_MEM\\\'
or, in shortened form:
! + \\\'_MEM\\\'
Note that the spaces are optional. When you press ENTER the designators of the components will be updated to U1_MEM, U3_MEM and U5_MEM respectively.
To illustrate the use of string-based functions consider the Copy function, which can be used to take a portion of an original string and place it within an expression to create a new string. Take again the Comms Port example (see Batch Replacement of String-based Attributes), where strings of the form CommPortx_8 need to be changed to IOPortx_32. In this case you could select the four free string objects, access the Smart Edit dialog for the String attribute and write the following expression on the Formula tab:
\\\'IO\\\' + Copy(String,5,6) + \\\'32\\\'
or, in shortened form:
\\\'IO\\\' + Copy(!,5,6) + \\\'32\\\'