Copy an analysis out to Notepad to edit it because it to too long to see on the edit window
and wonder why Intellisense isn't finishing my attribute or variable names as I type...
It happens to many of us. For a long analysis, did you try Shift+Enter to break it into multiple lines first?
Yes, it has been broken down to be readable; it is currently 28 lines.
A series of if/then/elseif blocks.
Generally, no need to change it, but trying to make it 'bullet proof' by adding checks for non-existent tags.
Added sections like:
if badval(TagName('<Level Tag>')) then
But then the local variable needed to replace the old attribute.
It is good practice to break analysis into multiple variables. This helps to not just improve human readability and there is really no need to map every variable to an attribute to make it work.
Breaking up into multiple lines does not resolve the problem trying to build a case statement with if/then/elseif. That still needs to be in one large block.
Looking at your example, would break the If/Then/Else ApPwAvg into multiple lines (Shift-Enter) to make it more readable. My rule of thumb is that you should be able the read the full expression on the display without scrolling.
After all, you don't write code for the computer or yourself, but for the next person fixing or changing your code in a few years time.
You are right. I was searching for an example which illustrates how to break up an analysis into multiple variables and agree that the one I picked isn't ideal for the reasons you pointed out.
Gregor, the analysis is broken into 6 sections already; only the last section has an output.
In the 'reading' pane, it is all visible; in the edit pane... not so much; it only shows 5 lines.
And, viewing this section as a whole, it is clear what it is doing - it just involves a series of nested if/then/else statements... and checking upper/lower limits on two attributes.
Retrieving data ...