PDA

View Full Version : Error commenting after "If...then"



EricE
08-06-2024, 08:19
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?

ErosOlmi
09-06-2024, 20: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

dco045
09-06-2024, 22:15
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.


Indent code


Best regards

Dany

ErosOlmi
10-06-2024, 14:34
Yes you are right.
I need to fix it asap, it is very annoying.

Just released thinBasic 1.13
Will work on this

ErosOlmi
11-06-2024, 20:58
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

Kinsonye
19-09-2024, 19:14
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.

etermark
23-09-2024, 15:31
Yeah, definitely avoid comments right after the "Then" in an If statement.