
The image above shows a formula property being edited, with text cut from Notepad and pasted into the edit pane. As you can see, the property references (text enclosed in square brackets) do not have the tell-tale gray background of a working property reference. (For ADT 2004 and 2005, the working property references appear in bold type.) After pasting, you could individually highlight each property reference and then double click on the corresponding property in the lower pane to replace the text with a working reference. In my simple example, that would only require three operations and would not be all that onerous. But for a more complex formula, there could be many more references, and the chore more tedious.
Fortunately, there is an alternative. You will need to scan through the code you intend to paste and identify all of the property references, but you would have to do that anyway, to make certain that all of those properties already existed. Keep a count of how many times each property is referenced. (If any one property is referenced more than two times, you may want to consider setting a variable to the value of that property up front, then using the variable in lieu of reading in the value multiple times.) As shown in the image below, add the property references in the code you intend to paste, one reference for each reference in the code, by double-clicking on the corresponding property in the lower pane. The sample code references the [HeightOverride] property twice and the [Height] property once, so that is what was added. Note the gray background behind the property references.

Now position the cursor before/above the property references you added. I like to throw a blank line or two before the references to be certain I am above them, and to make the final cleanup that much easier. Paste your code into the edit window and "presto-chango" - the code reference text you pasted in is now magically transformed into working code references, and the code references added prior to pasting are now plain text, as seen below.

All that remains is to highlight the extra lines and now useless text at the end of the formula and delete it.

Note: If the names of the properties in the code to be pasted are different from the equivalent properties in your Property Sets, you will need to paste the code to Notepad or a similar program and edit the name text to match your names before pasting it into the formula property, or this technique will not work.
No comments:
Post a Comment