Multiple line syntax comments

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

Multiple line syntax comments

Jim Moffitt
Sorry about the simple question, but I can't find an answer in any of my
SPSS books.
 
If I want to extend a comment in a syntax window to multiple lines must
I each new line with an asterisk?
 
I've tried beginning the first line with an asterisk and indenting the
subsequent lines, but I get error messages.
 
Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: Multiple line syntax comments

Oliver, Richard
Indenting the continuation lines should work -- but make sure that only the last line ends with a period. A period as the last non-blank character in a line is interpreted as the command terminator.

This should work:
*This is a comment with two sentences. The second
   sentence continues on the second line.

This will generate an error:
*This is a comment with two sentences.
   The second sentence continues on the second line.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jim Moffitt
Sent: Tuesday, July 11, 2006 3:34 PM
To: [hidden email]
Subject: Multiple line syntax comments

Sorry about the simple question, but I can't find an answer in any of my
SPSS books.

If I want to extend a comment in a syntax window to multiple lines must
I each new line with an asterisk?

I've tried beginning the first line with an asterisk and indenting the
subsequent lines, but I get error messages.

Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: Multiple line syntax comments

Jim Moffitt
Thanks, Richard.

-----Original Message-----
From: Oliver, Richard [mailto:[hidden email]]
Sent: Tuesday, July 11, 2006 4:03 PM
To: Moffitt, James (West); [hidden email]
Subject: RE: Multiple line syntax comments

Indenting the continuation lines should work -- but make sure that only
the last line ends with a period. A period as the last non-blank
character in a line is interpreted as the command terminator.

This should work:
*This is a comment with two sentences. The second
   sentence continues on the second line.

This will generate an error:
*This is a comment with two sentences.
   The second sentence continues on the second line.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Jim Moffitt
Sent: Tuesday, July 11, 2006 3:34 PM
To: [hidden email]
Subject: Multiple line syntax comments

Sorry about the simple question, but I can't find an answer in any of my
SPSS books.

If I want to extend a comment in a syntax window to multiple lines must
I each new line with an asterisk?

I've tried beginning the first line with an asterisk and indenting the
subsequent lines, but I get error messages.

Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: Multiple line syntax comments

Hector Maletta
Even without the indent. Indentation of continuation lines (in comments or
commands) is required only in production mode, I believe. For ordinary
syntax files under Windows, I understand that asterisked comments go on and
on, with an asterisk only in the first line, until a period is encountered.
Hector

-----Mensaje original-----
De: SPSSX(r) Discussion [mailto:[hidden email]] En nombre de Jim
Moffitt
Enviado el: Tuesday, July 11, 2006 6:06 PM
Para: [hidden email]
Asunto: Re: Multiple line syntax comments

Thanks, Richard.

-----Original Message-----
From: Oliver, Richard [mailto:[hidden email]]
Sent: Tuesday, July 11, 2006 4:03 PM
To: Moffitt, James (West); [hidden email]
Subject: RE: Multiple line syntax comments

Indenting the continuation lines should work -- but make sure that only
the last line ends with a period. A period as the last non-blank
character in a line is interpreted as the command terminator.

This should work:
*This is a comment with two sentences. The second
   sentence continues on the second line.

This will generate an error:
*This is a comment with two sentences.
   The second sentence continues on the second line.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Jim Moffitt
Sent: Tuesday, July 11, 2006 3:34 PM
To: [hidden email]
Subject: Multiple line syntax comments

Sorry about the simple question, but I can't find an answer in any of my
SPSS books.

If I want to extend a comment in a syntax window to multiple lines must
I each new line with an asterisk?

I've tried beginning the first line with an asterisk and indenting the
subsequent lines, but I get error messages.

Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: Multiple line syntax comments

Richard Ristow
In reply to this post by Jim Moffitt
At 04:34 PM 7/11/2006, Jim Moffitt wrote:

>If I want to extend a comment in a syntax window to multiple lines
>must I each new line with an asterisk? I've tried beginning the first
>line with an asterisk and indenting the subsequent lines, but I get
>error messages.

Hmmmm. It ought to work. Here's SPSS draft output, from a very simple
check:

ECHO 'Start of the example'.
Start of the example

*  This is the multi-line comment, where
    each line is a continuation and is
    indented, ending with a period.

ECHO 'End of the example'.
End of the example

Here's how it looks in the SPSS journal:

Tue Jul 11 19:25:54 2006 :journaling started
ECHO 'Start of the example'.

*  This is the multi-line comment, where
  each line is a continuation and is
  indented, ending with a period.

ECHO 'End of the example'.

Now, I've been bitten a couple of times by doing something like this,
but ending one of the lines with a period, which ends the command, so
the rest is read as syntax and is, of course, wrong. For example, this
syntax

ECHO 'New example which probably will not work'.

*  This is a multi-line commment.
    It looks like it ought to work as well
    as the earlier example, but look what
    happens.

ECHO 'End of the new example'.

gives this draft output

ECHO 'New example which probably will not work'.
New example which probably will not work

*  This is a multi-line commment.
    It looks like it ought to work as well

 >Error # 1.  Command name: It
 >The first word in the line is not recognized as an SPSS command.
 >This command not executed.

    as the earlier example, but look what
    happens.

ECHO 'End of the new example'.
End of the new example

.........................
All that said, "starting each new line with an asterisk" may be better
practice. Coding standards often discourage or forbid multi-line
comments, because it can be unclear, reading the code, what is within a
comment and what isn't. It's harder to write

*  This is a multi-line block of comments, .
*  each one beginning with an asterisk and .
*  ending with a period, so each is a      .
*  separate 'comment' statement.           .

but it's safer and clearer. I think it looks better, but you know I'm
fussy about aesthetics of code.
Reply | Threaded
Open this post in threaded view
|

Re: Multiple line syntax comments

Oliver, Richard
In reply to this post by Jim Moffitt
Any command processed under batch processing rules must indent continuation lines. This includes syntax files invoked with the INCLUDE command and command files run via SPSSB, a batch facility available with SPSS Server.

If a period is the last character in a line in either interactive or batch (production) mode, it is interpreted as the end of the command. (I think.)

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Hector Maletta
Sent: Tuesday, July 11, 2006 4:22 PM
To: [hidden email]
Subject: Re: Multiple line syntax comments

Even without the indent. Indentation of continuation lines (in comments or
commands) is required only in production mode, I believe. For ordinary
syntax files under Windows, I understand that asterisked comments go on and
on, with an asterisk only in the first line, until a period is encountered.
Hector

-----Mensaje original-----
De: SPSSX(r) Discussion [mailto:[hidden email]] En nombre de Jim
Moffitt
Enviado el: Tuesday, July 11, 2006 6:06 PM
Para: [hidden email]
Asunto: Re: Multiple line syntax comments

Thanks, Richard.

-----Original Message-----
From: Oliver, Richard [mailto:[hidden email]]
Sent: Tuesday, July 11, 2006 4:03 PM
To: Moffitt, James (West); [hidden email]
Subject: RE: Multiple line syntax comments

Indenting the continuation lines should work -- but make sure that only
the last line ends with a period. A period as the last non-blank
character in a line is interpreted as the command terminator.

This should work:
*This is a comment with two sentences. The second
   sentence continues on the second line.

This will generate an error:
*This is a comment with two sentences.
   The second sentence continues on the second line.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Jim Moffitt
Sent: Tuesday, July 11, 2006 3:34 PM
To: [hidden email]
Subject: Multiple line syntax comments

Sorry about the simple question, but I can't find an answer in any of my
SPSS books.

If I want to extend a comment in a syntax window to multiple lines must
I each new line with an asterisk?

I've tried beginning the first line with an asterisk and indenting the
subsequent lines, but I get error messages.

Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: Multiple line syntax comments

statisticsdoc
In reply to this post by Jim Moffitt
Stephen Brand
www.statisticsdoc.com

Richard -

A great deal of good advice has been given on this topic - let me just add a
side note.  Richard's point about using an asterisk to start each line of a
comment is sound advice.  I would also suggest making a habit of leaving a
blank line after the comment in case the ending period is omitted.  For
example, the recode statement in the following example will take effect:

*  OOPS I forgot the period before an important recode statement

RECODE THISVAR (1 2 = 9) .


However, in the following example, SPSS reads the recode statement as a part
of the comment, and does not execute it.

*  OOPS I forgot the period before an important recode statement
RECODE THISVAR (1 2 = 9) .

Just my five cents,

Stephen Brand


For personalized and professional consultation in statistics and research
design, visit
www.statisticsdoc.com


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Jim Moffitt
Sent: Tuesday, July 11, 2006 4:34 PM
To: [hidden email]
Subject: Multiple line syntax comments


Sorry about the simple question, but I can't find an answer in any of my
SPSS books.

If I want to extend a comment in a syntax window to multiple lines must
I each new line with an asterisk?

I've tried beginning the first line with an asterisk and indenting the
subsequent lines, but I get error messages.

Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: Multiple line syntax comments

Jim Moffitt
Thanks, Steve. That's a good idea.

-----Original Message-----
From: Statisticsdoc [mailto:[hidden email]]
Sent: Wednesday, July 12, 2006 8:31 AM
To: Moffitt, James (West); [hidden email]
Subject: RE: Multiple line syntax comments

Stephen Brand
www.statisticsdoc.com

Richard -

A great deal of good advice has been given on this topic - let me just
add a side note.  Richard's point about using an asterisk to start each
line of a comment is sound advice.  I would also suggest making a habit
of leaving a blank line after the comment in case the ending period is
omitted.  For example, the recode statement in the following example
will take effect:

*  OOPS I forgot the period before an important recode statement

RECODE THISVAR (1 2 = 9) .


However, in the following example, SPSS reads the recode statement as a
part of the comment, and does not execute it.

*  OOPS I forgot the period before an important recode statement RECODE
THISVAR (1 2 = 9) .

Just my five cents,

Stephen Brand


For personalized and professional consultation in statistics and
research design, visit www.statisticsdoc.com


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Jim Moffitt
Sent: Tuesday, July 11, 2006 4:34 PM
To: [hidden email]
Subject: Multiple line syntax comments


Sorry about the simple question, but I can't find an answer in any of my
SPSS books.

If I want to extend a comment in a syntax window to multiple lines must
I each new line with an asterisk?

I've tried beginning the first line with an asterisk and indenting the
subsequent lines, but I get error messages.

Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: Multiple line syntax comments

Richard Ristow
In reply to this post by statisticsdoc
At 09:30 AM 7/12/2006, Statisticsdoc wrote:

>Richard's point about using an asterisk to start each line of a
>comment is sound advice.  I would also suggest leaving a blank line
>after the comment in case the ending period is omitted.  For example,
>the recode statement in the following example will take effect:
>
>*  OOPS I forgot the period before an important recode statement
>
>RECODE THISVAR (1 2 = 9) .
>
>In the following example, SPSS reads the recode statement as a part
>of the comment, and does not execute it.
>
>*  OOPS I forgot the period before an important recode statement
>RECODE THISVAR (1 2 = 9) .

Yeah. Confession: I think I'm nigh as careful a coder as we've got; and
I've been bit by this one.