6 Replies Latest reply on Dec 7, 2018 1:35 PM by TimCarmichael

    Epic Fail Of The Day

    TimCarmichael

      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...

        • Re: Epic Fail Of The Day
          Rick Davin

          It happens to many of us.  For a long analysis, did you try Shift+Enter to break it into multiple lines first?

            • Re: Epic Fail Of The Day
              TimCarmichael

              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

                  -1

              else

                  '<Level Tag>'

               

              But then the local variable needed to replace the old attribute.

                • Re: Epic Fail Of The Day
                  gregor

                  Hello Tim,

                   

                  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.

                   

                    • Re: Epic Fail Of The Day
                      Roger Palmen

                      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.

                      1 of 1 people found this helpful
                      • Re: Epic Fail Of The Day
                        TimCarmichael

                        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.