Results 1 to 7 of 7

Thread: Error commenting after "If...then"

  1. #1
    Junior Member
    Join Date
    Apr 2023
    Posts
    3
    Rep Power
    0

    Error commenting after "If...then"

    This code has a comment at the end of the "If...then" line.
        If strTempValue = "C" Then ' Celsius
          strCommand = "DEGC"
        Else 'Fahrenheit
          strCommand = "DEGF"
        End If
    
    This results in an error message being displayed
    "Block warning: End of IF block found, but no matching beginning."

    The error message will go away if the trailing comment is removed.
        If strTempValue = "C" Then  
          strCommand = "DEGC"
        Else 'Fahrenheit
          strCommand = "DEGF"
        End If
    
    Should we simply avoid placing a comment on the same line after the "then" keyword?

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10
    Thanks for reporting.

    Error in thinAir parsing IF. It expects THEN keyword as last token in IF statement to decide if single or multiple line IF statement.
    I need to remove comments before parsing

    Will fix soon
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    Member
    Join Date
    Jan 2018
    Location
    France
    Age
    72
    Posts
    74
    Rep Power
    14

    Linked with other thread

    Quote Originally Posted by ErosOlmi View Post
    Thanks for reporting.

    Error in thinAir parsing IF. It expects THEN keyword as last token in IF statement to decide if single or multiple line IF statement.
    I need to remove comments before parsing

    Will fix soon
    Hi Eros,

    I think this thread joins with mine dated 07-05-2024.
    Quote Originally Posted by dco045 View Post
    Indent code
    Best regards

    Dany

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10
    Yes you are right.
    I need to fix it asap, it is very annoying.

    Just released thinBasic 1.13
    Will work on this
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10
    Forgot to mention ...
    thinBasic version 1.13 should have this bug fixed in thinAir.

    https://www.thinbasic.com/downloads.html#downloads

    If you can, please confirm it or just give me some examples not working

    As you may know thinBasic is able to parse also some different kind of comments like double // or single or multi line comments between /* ... */ used in other programming languages.
    Also those kind of commenting methods should now work at the end of a IF line
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  6. #6
    Junior Member
    Join Date
    Sep 2024
    Posts
    3
    Rep Power
    0
    Yeah, you should avoid putting comments on the same line as the "Then" keyword. Some compilers or interpreters don't handle inline comments well in control structures like this. Best practice is to place comments on their own line above or below the code to prevent these errors.

  7. #7
    Junior Member
    Join Date
    Jun 2023
    Posts
    7
    Rep Power
    2
    Yeah, definitely avoid comments right after the "Then" in an If statement.

Similar Threads

  1. Replies: 0
    Last Post: 28-02-2024, 18:52
  2. Replies: 9
    Last Post: 12-03-2016, 04:32
  3. Uses "File", "Crypto" ... ???
    By marcuslee in forum thinBasic General
    Replies: 3
    Last Post: 01-12-2009, 19:38

Members who have read this thread: 7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •