MACRO ALERT! Don't use End as a parameter name ;-(((

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

MACRO ALERT! Don't use End as a parameter name ;-(((

David Marso
Administrator
DEFINE !oops (Beg !TOKEN(1) / End !TOKENS(1) )
VECTOR v=!BEG TO !END.
LOOP i=1 TO 2.
COMPUTE v(i)=1.
END LOOP.
!ENDDEFINE.

DEFINE !ohCrap  (Beg !TOKEN(1) / End !TOKENS(1) )
DO REPEAT v=!BEG TO !END.
COMPUTE v=1
END REPEAT,
!ENDDEFINE.


The following BIZARRE behavior has been revealed ;-(((
---------------------------------------------------------------
SET MPRINT ON PRINTBACK ON.
DATA LIST FREE / X Y.
BEGIN DATA
1 2
END DATA.

!oops BEG=x END=y.

Ends up with:
VECTOR v= x TO y y.

!ohCrap BEG=x END=y.

Ends up with:
DO REPEAT v= x TO y y.

Looks like !End is somehow RESERVED. (maybe used internally to macro?)
Dear whoever please document this little weirdness??
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: MACRO ALERT! Don't use End as a parameter name ;-(((

Kirill Orlov
David, thank you for the alert.
However, I think that one wouldn't use !END as variable name because it so much resembles !ENDDEFINE.
Even if they are not mixed up in this specific case (I don't know if they are) we should always keep in mind the fact that SPSS allows to abbreviate command names.

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: MACRO ALERT! Don't use End as a parameter name ;-(((

David Marso
Administrator
http://spssx-discussion.1045642.n5.nabble.com/delete-duplicate-brand-names-in-the-concatenated-variable-td5729898.html

This is how the mystery came to light ;-)

Kirill Orlov wrote
David, thank you for the alert.
However, I think that one wouldn't use !END as variable name because it
so much resembles !ENDDEFINE.
Even if they are not mixed up in this specific case (I don't know if
they are) we should always keep in mind the fact that SPSS allows to
abbreviate command names.


=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: MACRO ALERT! Don't use End as a parameter name ;-(((

Richard Ristow
In reply to this post by David Marso
At least in SPSS 14, "!END."  is apparently accepted as a synonym for
"!ENDDEFINE.", although the Command Syntax Reference is quite
explicit to the contrary ("DEFINE and !ENDDEFINE must be spelled in
full. They cannot be abbreviated." -v.22 C.S.R., p. 525):

*  Macro /* !MacEcho */ is used to display the macro expansion   .
DEFINE !MacEcho(!POS !NOEXPAND !CMDEND)
     ECHO  !QUOTE(!CONCAT('     Call  : ',!1)).
     ECHO  !QUOTE(!CONCAT('     Result: ',!EVAL(!1))).
!ENDDEFINE.

DEFINE !Alpha ()
     A B C
!ENDDEFINE.

DEFINE !Beta ()
    D E F
!END.

!MacEcho !Alpha.
      Call  : !Alpha
      Result: A B C

!MacEcho !Beta.
      Call  : !Beta
      Result: D E F

So I guess this brings "!END" under the scope of the rule "Argument
names ... cannot match the character portion of a macro keyword, such
as DEFINE, TOKENS, CHAREND, and so forth" (-v22 C.S.R., p. 528).

But since the observed behavior, though consistent, explicitly
contradicts the documentation, the most charitable reasonable term is
"confusing."

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD