6 Replies Latest reply on Nov 3, 2015 10:25 PM by Fred(CH)

    Script Indenting is confused by commented If and End If script steps

    Malcolm

      Product and version:

      FileMaker Pro Advanced 14.0.3

       

      OS and version:

      Mac OS X 10.10.5

       

      Description:

      the indenting is based on all the If and End If script steps, even when some of those script steps are comments. The indenting error does not affect the correctness of the scripts.

       

      How to replicate:

      Create a script and insert several nested if/end if blocks. Delete one of the End If steps and comment one of the If steps. The active If/End If steps should be in balance, however, the script indentation does not reflect this.

       

       

      Workaround:

      None required, though the error in indentation is confusing and may cause the developer to make errors.

      Do not comment out if / end if script steps.

      Balance the commented if / end if script steps.

      Remove the commented if / end if  script steps.

        • 1. Re: Script Indenting is confused by commented If and End If script steps
          TSGal

          Malcolm:

           

          Thank you for your post.

           

          This post is better suited for the "Product Ideas" board at:  Product Ideas

           

          Typically, with source code, developers generally indent comments when the code is indented.  If you want to comment out an IF construct, then either comment out both the "If" and "End If" lines, or remove both steps.  If you want to keep the condition as a comment, then enter it as a comment.  That is, instead of creating the IF step and changing it to a comment (leaving the indentation), create a comment and enter the IF condition.

           

          TSGal

          FileMaker, Inc.

          • 2. Re: Script Indenting is confused by commented If and End If script steps
            Malcolm

            Hi TSGal,

             

            May I take umbrage with your response, "Typically, with source code, developers generally indent comments"?

             

            Typically, with source code, developers work in text editors where they have complete control over the layout of the code. If I was working in a text editor I would not have experienced the problem as the duplicated line would have been identical to the original.

             

            As I am working in the FileMaker Pro Script Workspace, I do not have the same level of control as I do in a text editor. As I am working the Script Workspace there are many behaviours which are outside my control. One of these behaviours is the indentation of code.

             

            As a developer ( or does your reply infer that I am not a developer because I am not working with source code? ) working in the Script Workspace I have to rely on the indentation that is forced on me by code which I cannot modify ( except by recourse to reporting the issue and hoping it is addressed in a future release ).

             

            As a developer, I read the code and I use the layout of the code as a guide. If I see two "End If" statements at the same level of indentation it signals an error earlier in the code. I will then search the code looking for the error. I have recently discovered that the indentation provided by the Script Workspace is not reliable. It will modify the layout of my code. May I repeat - I have no control over this - and the layout will not accurately reflect the state of the code. The layout of the code will suggest that there are errors in the code when there are not.

             

            If it were possible for me to over-ride the indentation forced on me by the Script Workspace I would agree with your suggestion. I could put in a feature request, along the lines of "please improve...". However, the issue is beyond my control and produces bad results. I think that is sufficient for me to describe it as an "issue" with the product and to raise this with FileMaker in the "Product Issues" area.

             

            Your other suggestions, in regard to code style, may be well-meaning but they all require me to take extra steps to work-around the errant behaviour of the Script Workspace. In effect, if I apply any of the work-arounds which I noted in my original report, the problem goes away. I have already taken those steps. However, the problem is with your product, not with my programming style. If a user is unaware of the issue and do not know that these extra steps are required, the problem will be evident. It hasn't be solved by telling me to code differently. Unfortunately, the group of people who are unaware of the issue are probably every other FileMaker Pro user in the world aside from you and I. Should we prepare a pro-forma email for them saying "Real developers don't comment their code in the way that you have... learn to write real code or suck it up."? I don't think that is an appropriate response and I am upset that you've decided to utilise it in this case.

            • 3. Re: Script Indenting is confused by commented If and End If script steps
              TSGal

              Malcolm:

               

              I apologize for my wording.  My intention was to not insinuate you aren't a developer.  I'm just speaking from my own developing experience and agreed upon standards when coding with teams of developers.  Every person has their own way of doing things.

               

              With that said, let me make sure I have the correct suggestion.  That is, when changing an "If" script step to a comment, you want the indentation removed.  Correct?


              Adding to that, do you want the corresponding "Else", "Else If" and End If" script steps also automatically commented or put into a different color?  Or the reverse?  That is, if you delete (or comment) an "End If" step, do you want the corresponding "If" step commented (along with "Else" and "Else If")?  Naturally, this would also apply to "Loop" and "End Loop".


              Would you like an alternate keyboard shortcut that would comment out an entire If/Loop construct?


              I have passed along your suggestion to our Development and Testing departments for discussion.

               

              Again, my apologies for the wording of my previous reply.

               

              TSGal

              FileMaker, Inc.

              • 4. Re: Script Indenting is confused by commented If and End If script steps
                Malcolm

                We simply want the indenting algorithm to recognise that disabled lines are commented out and have no effect on the code structure.

                 

                I'll describe the circumstances so that you can see what the use case is.

                 

                I have nested if statements:

                 

                if ( x = y )

                     if (  complex calc )

                          if ( a = b )

                               # many lines of code

                               if ( old conditions )

                                    # many lines of code

                               else if ( new conditions )

                               end if

                          end if

                     else

                          if ( old conditions )

                          else if ( new conditions )

                          end if

                     end if

                end if

                 

                The conditions affecting the complex calculation have changed and we need to adjust it. We know how it works, what results it produces and what the new conditions are that it does not address. So, we duplicate the line of code and disable one of them. We intend to test a new complex calculation. The success or failure of the new calculation will push us many lines below. We are using breakpoints to facilitate debugging. When we begin testing we notice that the structure of the code is odd. It is suggesting that there is a problem, yet the script was parsed and saved, so it should be correct. What is happening?

                 

                When we duplicate the line "if  ( complex calc )" the script workspace modifies the indentation of all subsequent lines. That is expected and desirable. When we disable one of the lines, we expect the disabled line to be treated as a comment and ignored by the layout algorithm. However, the algorithm that is used to determine indentation ignores the disabled flag and lays out the code as if the line was active. That is not expected and is undesirable behaviour.

                 

                The effect of the behaviour is this, when we are many lines below the disabled line the indentation of the code is wrong. It is extremely misleading and may cause the developer to make changes which are undesirable, breaking the code.

                 

                We do not want the corresponding end if to be commented out: that would cause terrible problems dozens of lines away!

                 

                We do not want any other changes. We simply want the indenting algorithm to recognise that disabled lines are commented out, that they have no effect on the code structure, and the code should be laid out accordingly.

                • 5. Re: Script Indenting is confused by commented If and End If script steps
                  TSGal

                  Malcolm:

                   

                  Thanks for your additional comments and clarification.

                   

                  Testing has informed me that the suggestion to not indent commented out If/Loop steps has been previously reported, and your post has been attached to that original report.

                   

                  TSGal

                  FileMaker, Inc.

                  • 6. Re: Script Indenting is confused by commented If and End If script steps
                    Fred(CH)

                    Dear Malcom,

                     

                    And since this behavior always been, the first suggestion TSGal about  Product Ideas may help you promoting this change request and who knows increase its prioritization.

                     

                    Bye, Fred