Call to a (nested?) macro

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

Call to a (nested?) macro

Luca Meyer
Can someone help me with the following:

(1) Within the main syntax I call a macro with something like:

!callmacro file1="c:\etc\etc\file1.sav" /file2="c:\etc\etc\file2.sav".

(2) the macro runs just file and later on I try a:

get file !file2.

but it doesn't work and I get:

>Warning # 210 in column 11.  Text: !file2
>A macro symbol is invalid in this context.

What am I doing wrong? I would like to avoid specifying again the same
file2="c:\etc\etc\file2.sav" before running get file....
Reply | Threaded
Open this post in threaded view
|

Re: Call to a (nested?) macro

Raynald Levesque
Hi

When you execute the line:

!callmacro file1="c:\etc\etc\file1.sav" /file2="c:\etc\etc\file2.sav".

The definition of file2="c:\etc\etc\file2.sav"
is only valid for this macro call.

Try  the following:


DEFINE !file2() "c:\etc\etc\file2.sav" !ENDDEFINE.

!callmacro file1="c:\etc\etc\file1.sav" /file2=!file2.

* then the following command will work.
get file !file2.

Regards,

Raynald Levesque [hidden email]
Website: www.spsstools.net

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Luca Meyer
Sent: March 24, 2007 3:59 AM
To: [hidden email]
Subject: Call to a (nested?) macro

Can someone help me with the following:

(1) Within the main syntax I call a macro with something like:

!callmacro file1="c:\etc\etc\file1.sav" /file2="c:\etc\etc\file2.sav".

(2) the macro runs just file and later on I try a:

get file !file2.

but it doesn't work and I get:

>Warning # 210 in column 11.  Text: !file2
>A macro symbol is invalid in this context.

What am I doing wrong? I would like to avoid specifying again the same
file2="c:\etc\etc\file2.sav" before running get file....
Reply | Threaded
Open this post in threaded view
|

Re: Call to a (nested?) macro

Albert-Jan Roskam
In reply to this post by Luca Meyer
Hi Luca,

It seems that you use macro argument '!file2' from
macro1 in macro2, probably without having specificed
it in the latter. Perhaps it would work with a !LET
statement and an !EVAL statement, e.g.

!LET !a = "c:\etc\etc\file1.sav".
!LET !b = "c:\etc\etc\file2.sav".

!EVAL(callmacro !a / !b).

get file = !b.


Note that I omitted the exclamation mark from your
macro name. I always wonder how a string is parsed in
a nested macro if that macro's name 'looks' like a
macro argument, ie. it has a "!" sign.

It's untested, but I hope it works. I ran into this a
couple of times and I never felt I thoroughly grasped
what was going on.

Cheers!!
Albert-Jan

--- Luca Meyer <[hidden email]> wrote:

> Can someone help me with the following:
>
> (1) Within the main syntax I call a macro with
> something like:
>
> !callmacro file1="c:\etc\etc\file1.sav"
> /file2="c:\etc\etc\file2.sav".
>
> (2) the macro runs just file and later on I try a:
>
> get file !file2.
>
> but it doesn't work and I get:
>
> >Warning # 210 in column 11.  Text: !file2
> >A macro symbol is invalid in this context.
>
> What am I doing wrong? I would like to avoid
> specifying again the same
> file2="c:\etc\etc\file2.sav" before running get
> file....
>


Cheers!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Did you know that 87.166253% of all statistics claim a precision of results that is not justified by the method employed? [HELMUT RICHTER]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



____________________________________________________________________________________
Don't get soaked.  Take a quick peek at the forecast
with the Yahoo! Search weather shortcut.
http://tools.search.yahoo.com/shortcuts/#loc_weather