Comment /* */ generates errors

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Comment /* */ generates errors

PRogman
I have discovered some strange behavior when commenting syntax.  A comment using the '/* text */' format generates errors or makes the syntax color coding fail in some cases. It seems to be the closing '*/' that triggers the error.
Has it always been like this, or is my system flaky?
/PR

*********************.
DATA LIST LIST /
A  B (2F8.0).
BEGIN DATA
1  1
END DATA.
DATASET NAME CommentErrors.

COMPUTE C = A * B.
EXECUTE. /* error: EXECUTE Unrecognized text appears on the EXECUTE command.  This command allows no subcommands. */.
EXECUTE.

COMPUTE D = A * B.  /*error: COMPUTE Incorrect variable name: either the name is more than 64 characters, or it is not defined by a previous command. */.
EXECUTE.

COMPUTE E = A * B.  /*works.
EXECUTE.

COMPUTE F = A * B.  
/*works*/.
EXECUTE.

IF (A EQ 1) G = A * B.  /*works.
EXECUTE.

IF (A EQ 1) H = A * B.  /*error*/.
EXECUTE.

COMPUTE J = 0.
LOOP # = 1 TO 10. /*loop works, syntax check 'loop-end loop' works */.
  COMPUTE J = J + A.
END LOOP.  
EXECUTE.

COMPUTE J = 0.
LOOP # = 1 TO 10.
  COMPUTE J = J + A.
END LOOP.  /*loop works, but comment make syntax color coding 'loop-end loop' fail, also 'do if-end if'...*/.
EXECUTE.
*********************.
Reply | Threaded
Open this post in threaded view
|

Re: Comment /* */ generates errors

Art Kendall
/* */.  with the period causes error message problem


COMPUTE C = A * B.
EXECUTE. /* error: EXECUTE Unrecognized text appears on the EXECUTE command.  This command allows no subcommands. */.  << remove this period

COMPUTE D = A * B.  /*error: COMPUTE Incorrect variable name: either the name is more than 64 characters, or it is not defined by a previous command. */.  << remove this period
EXECUTE.

Removing the period does not fix the LOOP coloring in the syntax window.
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Comment /* */ generates errors

jkpeck
In reply to this post by PRogman
As Art said, the periods should not appear after the end of the comment.  Think of /*...*/ as just blank space, so the EXECUTE command becoems
EXECUTE..
which is, of course, invalid.

I don't see a problem with the LOOP block in the SE in either V27 or V28 as long as that extra period is removed.
Reply | Threaded
Open this post in threaded view
|

Re: Comment /* */ generates errors

Bruce Weaver
Administrator
In reply to this post by Art Kendall
Well-spotted, Art.  

Here is a revised version of Andy's code with the offending periods removed and comments amended suitably.  I also added one other variation on Andy's LOOP that causes something very odd to happen to the colour-coding of the COMPUTE commands:  When I start the line with ., + or - to make the nesting clearer, the final E on each COMPUTE command has no colour-coding.  COMPUT has colour-coding, but not the final E.  Very strange!  

DATA LIST LIST /
A  B (2F8.0).
BEGIN DATA
1  1
END DATA.
DATASET NAME CommentErrors.

COMPUTE C = A * B.
EXECUTE. /* Works, but no colour-coding on either EXECUTE command */
EXECUTE.

COMPUTE D = A * B.  /* Works, but no colour-coding on EXECUTE */
EXECUTE.

COMPUTE E = A * B.  /*works.
EXECUTE.

COMPUTE F = A * B.  
/*works, but no colour-coding on EXECUTE */
EXECUTE.

IF (A EQ 1) G = A * B.  /*works.
EXECUTE.

IF (A EQ 1) H = A * B.  /* Works, but no colour-coding on EXECUTE */
EXECUTE.

COMPUTE J = 0.
LOOP # = 1 TO 10. /*loop works, no colour coding on COMPUTE */
 COMPUTE J = J + A.
END LOOP.  
EXECUTE.

COMPUTE J = 0.
LOOP # = 1 TO 10.
  COMPUTE J = J + A.
END LOOP.  /* Works, but LOOP is red, no colour-coding for END LOOP or EXECUTE */
EXECUTE.

* Here is one more Andy did not include.
* The next structure generates no errors, but the final E on
* each COMPUTE is NOT colour-coded.  I've noticed this for years,
* and always found it very strange.
LOOP # = 1 TO 10.
. COMPUTE X = J + A.
+ COMPUTE Y = J + A.
- COMPUTE Z = J + A.
END LOOP.  
EXECUTE.



Art Kendall wrote
/* */.  with the period causes error message problem


COMPUTE C = A * B.
EXECUTE. /* error: EXECUTE Unrecognized text appears on the EXECUTE command.  This command allows no subcommands. */.  << remove this period

COMPUTE D = A * B.  /*error: COMPUTE Incorrect variable name: either the name is more than 64 characters, or it is not defined by a previous command. */.  << remove this period
EXECUTE.

Removing the period does not fix the LOOP coloring in the syntax window.
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Comment /* */ generates errors

Kirill Orlov
In reply to this post by PRogman
To my mind, typical scenarios of in-line commenting are

compute x= 1. /*comment
execute.

compute x= /*comment*/ 1.
execute.

compute x= /*comment
  1.
execute.

No period should go after the /* */ (which is actually needed only when comment is within a line of command).

In the beginning of a line, we usually use:
*comment.
compute x= 1.

However, practice shows that inside a macro body /* is more reliable than * even in the beginning of a line:
/*comment.
compute x= 1.