Comment ignored if open brace is present

Homepage Clovertech Forums Cloverleaf Comment ignored if open brace is present

  • Creator
    Topic
  • #120960
    Doug Haskins
    Participant

    When working with tcl in script editor, comments are ignored if there is an open brace in the line. If I have something using if, or for, and other things, if I comment one line out and add an alternate, the comment is ignored and it errors when I go to save it.

    I added a simple example in the attachment.

    If I close off the brace in the comment it works, but this is ridiculous. Is there a way to stop it erroring for things inside a comment? Maybe stop  it even looking at things that are commented out?

    Attachments:
    You must be logged in to view attached files.
Viewing 2 reply threads
  • Author
    Replies
    • #120962
      Charlie Bursell
      Participant

      A property of Tcl comments is that curly braces or brackets inside comments are still counted for the purposes of finding matching brackets. The motivation for this odd feature was to keep the original Tcl parser simpler.   A # starts a comment prior to a command which means it can be the first character on a line or after a command with the ; character which ends a command.  The # character is not treated as a special character elsewhere.

      It would be very confusing for the parser to know if the brace or bracket was part of a command or not.

      I use the % character in Vi to find matching brackets, braces and quotes in a proc when I have a Tcl error that is not obvious.  So even though you can put bracket lie { or } inside comments, I always balance them to aid in troubleshooting.  One good trick if using Vi or other supporting editors is to put your cursor to the firs { in the proc and hit %.  It should go to the last }.  I always to this prior to saving a proc.

      All languages have quirks you have to live with 🙂

       

    • #120963
      Jim Kosloskey
      Participant

      I would prefer the Script editor give me the warning rather than waiting to execute the proc and then getting the error.

      I don’t know about others, but the error tracing when the unmatched brace error is thrown at execution leaves me thrashing around some (even using some of the tricks I have learned from Charlie).

      So, as long as Tcl has this issue, and if I used the Script Editor (which I do not), I would welcome the observed warning.

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

    • #120964
      Doug Haskins
      Participant

      The other annoying thing is that the parser checks all of your procs when you go to save it, so if you comment something out with the issue listed above, and then move to a different proc, when you try to save the one you are working on, it will flag the error in the other proc. This is confusing.

      What do you use in place of script editor? I know notepad++ has some tcl abilities.

      • #120965
        Jim Kosloskey
        Participant

        I have used notepad++ (with Tcl extensions) and Ultra-Edit (also with Tcl extensions). I have also used the script editor – just not as much.

        email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,292
Replies
34,435
Topic Tags
286
Empty Topic Tags
10