Quoting a macro variable

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

Quoting a macro variable

Sundance Kid
Hi there,

I have a macro construct like this:



DEFINE macroexport ()




insert file= 'C:\unit_code_for_export.sps'.




* Export Output.
OUTPUT EXPORT
  /CONTENTS  EXPORT=VISIBLE  LAYERS=PRINTSETTING  MODELVIEWS=PRINTSETTING
  /XLS  DOCUMENTFILE=!Path1 + !arg4
     OPERATION=CREATEFILE
     LOCATION=LASTCOLUMN  NOTESCAPTIONS=YES.

!ENDDEFINE.


macroexport

The file unit_code_for_export.sps has the value of !arg4 written to it (from using another macro). So for example it might hold the code 2000D.xls. !Path1 is already defined in another macro as a quoted path. If the value passed to !arg4 already has quotation (single apostrophe) marks around it the code and macroexport call works. So if the code held in !arg4 is '2000D.xls' then the macro works. But I want to quote the value of !arg4 in the macro above - NOT beforehand. So if I write: !Path1 + '!arg4' this only produces a file with the macro variable in the name. I have tried  !Path1 + !quote(!arg4) but this does not pass the value in !arg4 to the file name. Can you tell me how to get the correct fiel name exported?

So if !Path1 evaluates to C:\ I want my filename to be C:\2000D.xls
Reply | Threaded
Open this post in threaded view
|

Re: Quoting a macro variable

David Marso
Administrator
Try something like this:
DEFINE !Path1 ()
'C:\'
!ENDDEFINE.

DEFINE !arg4 ()
'test.xls'
!ENDDEFINE.

DEFINE !blah ()
ECHO !QUOTE(!CONCAT(!UNQUOTE(!path1),!UNQUOTE(!arg4))).
!ENDDEFINE .

SET MPRINT ON PRINTBACK ON.
!blah.


Sundance Kid wrote
Hi there,

I have a macro construct like this:



DEFINE macroexport ()




insert file= 'C:\unit_code_for_export.sps'.




* Export Output.
OUTPUT EXPORT
  /CONTENTS  EXPORT=VISIBLE  LAYERS=PRINTSETTING  MODELVIEWS=PRINTSETTING
  /XLS  DOCUMENTFILE=!Path1 + !arg4
     OPERATION=CREATEFILE
     LOCATION=LASTCOLUMN  NOTESCAPTIONS=YES.

!ENDDEFINE.


macroexport

The file unit_code_for_export.sps has the value of !arg4 written to it (from using another macro). So for example it might hold the code 2000D.xls. !Path1 is already defined in another macro as a quoted path. If the value passed to !arg4 already has quotation (single apostrophe) marks around it the code and macroexport call works. So if the code held in !arg4 is '2000D.xls' then the macro works. But I want to quote the value of !arg4 in the macro above - NOT beforehand. So if I write: !Path1 + '!arg4' this only produces a file with the macro variable in the name. I have tried  !Path1 + !quote(!arg4) but this does not pass the value in !arg4 to the file name. Can you tell me how to get the correct fiel name exported?

So if !Path1 evaluates to C:\ I want my filename to be C:\2000D.xls
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?"