Macro, where the dots come and go

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Macro, where the dots come and go

Richard Ristow
OK, macros manipulate text in, sometimes, strange ways. But I truly
don't see how a straightforward

   !LET  !Name = !CONCAT(X,!LENGTH(!1))
.  LOOP !Name = !HEAD(!2) TO !HEAD(!3) BY !HEAD(!4).

.     LEAVE ALL.
.     END CASE.

.  END LOOP.

generated the code

   33 M>
   34 M>  .
   35 M>  . LOOP X0 = 1 TO 1 BY 1.
   36 M>  LEAVE ALL.
   37 M>  END CASE.
   38 M>  END LOOP.
   39 M>  .

All four native SPSS statements begin with a period and some spaces.
Why are the period and spaces retained on the LOOP statement, but
removed from the other three?

What are the sources for the period that precedes the LOOP statement,
and the one that follows the END LOOP?
====================
APPENDIX  I: Listing
====================
DEFINE !OneLoop (!POS !CHAREND ("/")
                 / !POS !CHAREND ("/")
                 / !POS !CHAREND ("/")
                 / !POS !CMDEND !DEFAULT(1))

!IF (!2 !NE !NULL) !THEN
   !LET  !Name = !CONCAT(X,!LENGTH(!1))
.  LOOP !Name = !HEAD(!2) TO !HEAD(!3) BY !HEAD(!4).

.     LEAVE ALL.
.     END CASE.

.  END LOOP.
!IFEND
!ENDDEFINE

NEW FILE.
INPUT PROGRAM.

PRESERVE.
SET PRINTBACK ON MPRINT ON.

   31 M>
!OneLoop  /1 2 3 4 5 6  7 8 9  9
           /1 5 6 8 8 9 10 9 9 10
           /1 1 1 2 1 1  2 1 1  1.
   33 M>
   34 M>  .
   35 M>  . LOOP X0 = 1 TO 1 BY 1.
   36 M>  LEAVE ALL.
   37 M>  END CASE.
   38 M>  END LOOP.
   39 M>  .

   40 M>
RESTORE.
   41 M>  RESTORE.
END FILE.
END INPUT PROGRAM.
EXECUTE.
SHOW N.

  SHOW
|-----------------------------|---------------------------|
|Output Created               |04-JAN-2014 20:39:56       |
|-----------------------------|---------------------------|
System Settings
|-------|---------------|-------|
|Keyword|Description    |Setting|
|-------|---------------|-------|
|N      |Number of cases|1      |
|       |in the working |       |
|       |data file      |       |
|-------|---------------|-------|
=================
APPENDIX II: code
=================
DEFINE !OneLoop (!POS !CHAREND ("/")
                 / !POS !CHAREND ("/")
                 / !POS !CHAREND ("/")
                 / !POS !CMDEND !DEFAULT(1))

!IF (!2 !NE !NULL) !THEN
   !LET  !Name = !CONCAT(X,!LENGTH(!1))
.  LOOP !Name = !HEAD(!2) TO !HEAD(!3) BY !HEAD(!4).

.     LEAVE ALL.
.     END CASE.

.  END LOOP.
!IFEND
!ENDDEFINE

NEW FILE.
INPUT PROGRAM.

PRESERVE.
SET PRINTBACK ON MPRINT ON.

!OneLoop  /1 2 3 4 5 6  7 8 9  9
           /1 5 6 8 8 9 10 9 9 10
           /1 1 1 2 1 1  2 1 1  1.

RESTORE.
END FILE.
END INPUT PROGRAM.
EXECUTE.
SHOW N.

=====================
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