Creating computer directories using macro arguments

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

Creating computer directories using macro arguments

Carlos Renato
Dear friends of SPSSX List

     I have a problem. I want to create computer directories using macros. 
The HOST COMMAND provides the use of DOS commands for example
MD path01 to create a directorie named path01. 
     Really, I want to create folders using macro arguments names as their names.


Carlos Renato
Statistician | M.Sc. Production Enginnering
Reply | Threaded
Open this post in threaded view
|

Re: Creating computer directories using macro arguments

David Marso
Administrator
So what is preventing you from doing this?

Carlos Renato dos Santos-2 wrote
Dear friends of SPSSX List

     I have a problem. I want to create computer directories using macros.
The HOST COMMAND provides the use of DOS commands for example
MD path01 to create a directorie named path01.
     Really, I want to create folders using macro arguments names as their
names.


Carlos Renato
Statistician | M.Sc. Production Enginnering
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: Creating computer directories using macro arguments

Carlos Renato
Dear friend

In fact, HOST command does not allow macro arguments within quotes in its syntax.
 I wonder if there is a way to create folders whose names were arguments macros.

HOST COMMAND=['command' 'command'...'command']

For example, I want to create two folders named f1 and f2. And I want make this using f1 and f2 with
macro arguments.

DEFINE MacroCreateFolders (!POSITIONAL !CMDEND)

commands

!ENDDEFINE.

MacroCreateFolders f1 f2.

Is it possible? Thanks for all responses.

Carlos Renato
Statistician - Brazil
Reply | Threaded
Open this post in threaded view
|

Re: Creating computer directories using macro arguments

David Marso
Administrator
Carlos,
My version does not support host command ;-(
Does something like:
HOST COMMAND=[!QUOTE(!macroarg)] .
work?
David

Carlos Renato wrote
*Dear friend*
*
*
*In fact, HOST command does not allow macro arguments within quotes in its
syntax.*
* I wonder if there is a way to create folders whose names were arguments
macros.*
*
*
*HOST COMMAND=['command' 'command'...'command']*
*
*
*For example, I want to create two folders named f1 and f2. And I want make
this using f1 and f2 with*
*macro arguments.*
*
*
*DEFINE MacroCreateFolders (!POSITIONAL !CMDEND)*
*
*
*commands*
*
*
*!ENDDEFINE.*
*
*
*MacroCreateFolders f1 f2.
*
*Is it possible? Thanks for all responses.*
*
*
*Carlos Renato*
*Statistician - Brazil*
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: Creating computer directories using macro arguments

Carlos Renato
In reply to this post by Carlos Renato
Dear friends of list

     In mid-2006 participated more actively in this list where I learned a lot. 
Now at the end of 2011 I am returning to study problems of manipulation in SPSS
and unfortunately, despite this simpleproblem, I'm not getting resolved. 
I am grateful for every contribution you can at least guide my thinking. Thank you.

Carlos Renato
Statistician - Brazil
Reply | Threaded
Open this post in threaded view
|

Automatic reply: Creating computer directories using macro arguments

Tierney, Mary Lou

I will be out of the office Tuesday throughThursday October 25-27 at a conference.  I will respond to email in the evenings.

 

For assistance with MIP Project set-up, please contact Claudia Froberg.

 

For assistance with Idea Market please contact the [hidden email].

 

For assistance with Project Pages or Discover, please contact the [hidden email]

 

For assistance with other Innovation Zone sites, please contact [hidden email].

 

Regards, Mary Lou

 

Reply | Threaded
Open this post in threaded view
|

Re: Creating computer directories using macro arguments

Art Kendall
In reply to this post by Carlos Renato
Please give more detail.

Why do you want to use macros rather than python? Legacy applications?

What do you want the contents of the macro variables to be?
Please give a few examples of sets of arguments and what you want the syntax generated by the macro to be given those arguments.

Also please
describe the overall goal of using the macro.

 
Art Kendall
Social Research Consultants

On 10/25/2011 9:38 AM, Carlos Renato dos Santos wrote:
Dear friends of list

     In mid-2006 participated more actively in this list where I learned a lot. 
Now at the end of 2011 I am returning to study problems of manipulation in SPSS
and unfortunately, despite this simpleproblem, I'm not getting resolved. 
I am grateful for every contribution you can at least guide my thinking. Thank you.

Carlos Renato
Statistician - Brazil
===================== 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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Creating computer directories using macro arguments

David Marso
Administrator
In reply to this post by Carlos Renato
Carlos,
Did you bother to try my suggestion?
What was the outcome?
If HOST does NOT allow !QUOTE(!arg) then you are SOL aside from some
sort of Pythonesque solution.
David

On Tue, Oct 25, 2011 at 9:53 AM, Carlos Renato [via SPSSX Discussion]
<[hidden email]> wrote:

> Dear friends of list
>      In mid-2006 participated more actively in this list where I learned a
> lot.
> Now at the end of 2011 I am returning to study problems of manipulation in
> SPSS
> and unfortunately, despite this simpleproblem, I'm not getting resolved.
> I am grateful for every contribution you can at least guide my
> thinking. Thank you.
> Carlos Renato
> Statistician - Brazil
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://spssx-discussion.1045642.n5.nabble.com/Creating-computer-directories-using-macro-arguments-tp4932558p4936292.html
> To unsubscribe from Creating computer directories using macro arguments,
> click here.
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: Creating computer directories using macro arguments

Jon K Peck
In reply to this post by Carlos Renato
Here is a simple example of using a macro with HOST.

define !mac () "c:/temp" !enddefine.
host command=["dir" !mac].

You could also build the entire command, including the host part, with the macro processor.

This sort of thing, though, is easier and more powerful if done with Python programmability, which you can get started with at
www.ibm.com/developerworks/spssdevcentral

Jon Peck (no "h")
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        Carlos Renato dos Santos <[hidden email]>
To:        [hidden email]
Date:        10/25/2011 06:44 AM
Subject:        Re: [SPSSX-L] Creating computer directories using macro arguments
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Dear friends of list

     In mid-2006 participated more actively in this list where I learned a lot. 
Now at the end of 2011 I am returning to study problems of manipulation in SPSS
and unfortunately, despite this simpleproblem, I'm not getting resolved. 
I am grateful for every contribution you can at least guide my thinking. Thank you.

Carlos Renato
Statistician - Brazil
Reply | Threaded
Open this post in threaded view
|

Re: Creating computer directories using macro arguments

Bruce Weaver
Administrator
To create a directory, it would be "mkdir" or "md".  I.e.,

host command=["mkdir" !mac].

OR...

host command=["md" !mac].


Jon K Peck wrote
Here is a simple example of using a macro with HOST.

define !mac () "c:/temp" !enddefine.
host command=["dir" !mac].

You could also build the entire command, including the host part, with the
macro processor.

This sort of thing, though, is easier and more powerful if done with
Python programmability, which you can get started with at
www.ibm.com/developerworks/spssdevcentral

Jon Peck (no "h")
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:   Carlos Renato dos Santos <[hidden email]>
To:     [hidden email]
Date:   10/25/2011 06:44 AM
Subject:        Re: [SPSSX-L] Creating computer directories using macro
arguments
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



Dear friends of list

     In mid-2006 participated more actively in this list where I learned a
lot.
Now at the end of 2011 I am returning to study problems of manipulation in
SPSS
and unfortunately, despite this simpleproblem, I'm not getting resolved.
I am grateful for every contribution you can at least guide my
thinking. Thank you.

Carlos Renato
Statistician - Brazil
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Creating computer directories using macro arguments

David Marso
Administrator
From what I can tell from a brief perusal of the FM (I may be wrong ;-)
Host expects the command to be in quotes:  per example.
Example
HOST COMMAND=['dir c:\myfiles\*.sav'].
It would appear that the resolution would involve something like the following:
DEFINE makedir ( path !CMDEND ).
HOST COMMAND [ !QUOTE(!CONCAT("MKDIR ",!path) ) ] .
!ENDDEFINE .
I can't test this here.  If one has embedded spaces in the path then you will have to account for that.
IIRC:  one would normally have to do MKDIR "C:\some path with spaces"
Host would *PROBABLY BE*
HOST COMMAND ['MKDIR "C:\some path with spaces"'].

Maybe
HOST COMMAND [ !QUOTE(!CONCAT("MKDIR" ,!QUOTE (!path) )) ].
OTOH, I am not in a position to test this and I leave it to Carlos to experiment and follow up with the suggestions.
?? Is the documentation wrong WRT requiring quoted command strings??
If *NOT* then ignore everything I have said ;-)  
OTOH I might be right but can't test it.
HTH, David





Bruce Weaver wrote
To create a directory, it would be "mkdir" or "md".  I.e.,

host command=["mkdir" !mac].

OR...

host command=["md" !mac].


Jon K Peck wrote
Here is a simple example of using a macro with HOST.

define !mac () "c:/temp" !enddefine.
host command=["dir" !mac].

You could also build the entire command, including the host part, with the
macro processor.

This sort of thing, though, is easier and more powerful if done with
Python programmability, which you can get started with at
www.ibm.com/developerworks/spssdevcentral

Jon Peck (no "h")
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:   Carlos Renato dos Santos <[hidden email]>
To:     [hidden email]
Date:   10/25/2011 06:44 AM
Subject:        Re: [SPSSX-L] Creating computer directories using macro
arguments
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



Dear friends of list

     In mid-2006 participated more actively in this list where I learned a
lot.
Now at the end of 2011 I am returning to study problems of manipulation in
SPSS
and unfortunately, despite this simpleproblem, I'm not getting resolved.
I am grateful for every contribution you can at least guide my
thinking. Thank you.

Carlos Renato
Statistician - Brazil
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: Creating computer directories using macro arguments

Albert-Jan Roskam
I sent this working solution to him off-list:

DEFINE MacroCreateFolders (!POSITIONAL !CMDEND)
!do !theDir !in (!1).
HOST COMMAND = !concat("['md ",  !unquote(!theDir), "'", "]")
!doend.
!ENDDEFINE.
MacroCreateFolders "d:\temp1" "d:\temp2" "d:\temp3".
 
Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: David Marso <[hidden email]>
To: [hidden email]
Sent: Tuesday, October 25, 2011 5:51 PM
Subject: Re: [SPSSX-L] Creating computer directories using macro arguments

From what I can tell from a brief perusal of the FM (I may be wrong ;-)
Host expects the command to be in quotes:  per example.
Example
HOST COMMAND=['dir c:\myfiles\*.sav'].
It would appear that the resolution would involve something like the
following:
DEFINE makedir ( path !CMDEND ).
HOST COMMAND [ !QUOTE(!CONCAT("MKDIR ",!path) ) ] .
!ENDDEFINE .
I can't test this here.  If one has embedded spaces in the path then you
will have to account for that.
IIRC:  one would normally have to do MKDIR "C:\some path with spaces"
Host would *PROBABLY BE*
HOST COMMAND ['MKDIR "C:\some path with spaces"'].

Maybe
HOST COMMAND [ !QUOTE(!CONCAT("MKDIR" ,!QUOTE (!path) )) ].
OTOH, I am not in a position to test this and I leave it to Carlos to
experiment and follow up with the suggestions.
?? Is the documentation wrong WRT requiring quoted command strings??
If *NOT* then ignore everything I have said ;-)
OTOH I might be right but can't test it.
HTH, David






Bruce Weaver wrote:

>
> To /create/ a directory, it would be "mkdir" or "md".  I.e.,
>
> host command=["mkdir" !mac].
>
> OR...
>
> host command=["md" !mac].
>
>
>
> Jon K Peck wrote:
>>
>> Here is a simple example of using a macro with HOST.
>>
>> define !mac () "c:/temp" !enddefine.
>> host command=["dir" !mac].
>>
>> You could also build the entire command, including the host part, with
>> the
>> macro processor.
>>
>> This sort of thing, though, is easier and more powerful if done with
>> Python programmability, which you can get started with at
>> www.ibm.com/developerworks/spssdevcentral
>>
>> Jon Peck (no "h")
>> Senior Software Engineer, IBM
>> peck@.ibm
>> new phone: 720-342-5621
>>
>>
>>
>>
>> From:  Carlos Renato dos Santos &lt;estatistico.com@&gt;
>> To:    SPSSX-L@.uga
>> Date:  10/25/2011 06:44 AM
>> Subject:        Re: [SPSSX-L] Creating computer directories using macro
>> arguments
>> Sent by:        "SPSSX(r) Discussion" &lt;SPSSX-L@.uga&gt;
>>
>>
>>
>> Dear friends of list
>>
>>      In mid-2006 participated more actively in this list where I learned
>> a
>> lot.
>> Now at the end of 2011 I am returning to study problems of manipulation
>> in
>> SPSS
>> and unfortunately, despite this simpleproblem, I'm not getting resolved.
>> I am grateful for every contribution you can at least guide my
>> thinking. Thank you.
>>
>> Carlos Renato
>> Statistician - Brazil
>>
>


--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Creating-computer-directories-using-macro-arguments-tp4932558p4936733.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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: Creating computer directories using macro arguments

Albert-Jan Roskam
In reply to this post by David Marso
This is a Python solution. Not sure if the macro handled file names with spaces well.
>>> dirs = ["d:\\temp files" + str(i) for i in range(10)]
>>>import os
>>> map(os.mkdir, dirs)
 
Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: David Marso <[hidden email]>
To: [hidden email]
Sent: Tuesday, October 25, 2011 5:51 PM
Subject: Re: [SPSSX-L] Creating computer directories using macro arguments

From what I can tell from a brief perusal of the FM (I may be wrong ;-)
Host expects the command to be in quotes:  per example.
Example
HOST COMMAND=['dir c:\myfiles\*.sav'].
It would appear that the resolution would involve something like the
following:
DEFINE makedir ( path !CMDEND ).
HOST COMMAND [ !QUOTE(!CONCAT("MKDIR ",!path) ) ] .
!ENDDEFINE .
I can't test this here.  If one has embedded spaces in the path then you
will have to account for that.
IIRC:  one would normally have to do MKDIR "C:\some path with spaces"
Host would *PROBABLY BE*
HOST COMMAND ['MKDIR "C:\some path with spaces"'].

Maybe
HOST COMMAND [ !QUOTE(!CONCAT("MKDIR" ,!QUOTE (!path) )) ].
OTOH, I am not in a position to test this and I leave it to Carlos to
experiment and follow up with the suggestions.
?? Is the documentation wrong WRT requiring quoted command strings??
If *NOT* then ignore everything I have said ;-)
OTOH I might be right but can't test it.
HTH, David






Bruce Weaver wrote:

>
> To /create/ a directory, it would be "mkdir" or "md".  I.e.,
>
> host command=["mkdir" !mac].
>
> OR...
>
> host command=["md" !mac].
>
>
>
> Jon K Peck wrote:
>>
>> Here is a simple example of using a macro with HOST.
>>
>> define !mac () "c:/temp" !enddefine.
>> host command=["dir" !mac].
>>
>> You could also build the entire command, including the host part, with
>> the
>> macro processor.
>>
>> This sort of thing, though, is easier and more powerful if done with
>> Python programmability, which you can get started with at
>> www.ibm.com/developerworks/spssdevcentral
>>
>> Jon Peck (no "h")
>> Senior Software Engineer, IBM
>> peck@.ibm
>> new phone: 720-342-5621
>>
>>
>>
>>
>> From:  Carlos Renato dos Santos &lt;estatistico.com@&gt;
>> To:    SPSSX-L@.uga
>> Date:  10/25/2011 06:44 AM
>> Subject:        Re: [SPSSX-L] Creating computer directories using macro
>> arguments
>> Sent by:        "SPSSX(r) Discussion" &lt;SPSSX-L@.uga&gt;
>>
>>
>>
>> Dear friends of list
>>
>>      In mid-2006 participated more actively in this list where I learned
>> a
>> lot.
>> Now at the end of 2011 I am returning to study problems of manipulation
>> in
>> SPSS
>> and unfortunately, despite this simpleproblem, I'm not getting resolved.
>> I am grateful for every contribution you can at least guide my
>> thinking. Thank you.
>>
>> Carlos Renato
>> Statistician - Brazil
>>
>


--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Creating-computer-directories-using-macro-arguments-tp4932558p4936733.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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: Creating computer directories using macro arguments

Carlos Renato
Dear partners

     Thanks for all suggestions. Finally, the whole question is this set of concatenate and put 
quotation marks at the right time.Although simple, it sometimes leaves us stuck at work.

DEFINE makedir (path !CMDEND ).
HOST COMMAND = [ !QUOTE(!CONCAT("MKDIR ",!path) ) ] .
!ENDDEFINE .

makedir path=Path1 Path2.

Tested and approved.

The problem was solved. Very much thanks to:
Albert-Jan Roskam, Bruce Weaver, David Marso, Jon Peck, Art Kendall and others
that help me.

Carlos Renato
Statistician - Brazil
Reply | Threaded
Open this post in threaded view
|

Re: Creating computer directories using macro arguments

David Marso
Administrator
Hint for debugging macros.
Issue
SET MPRINT ON.
The generated syntax will show up in the output and you can see where
things are missing.
If you are attempting to create multiple folders in a single macro
invocation you will want to add a list processing loop as in
Albert-Jans version.
!DO (!V !IN !args)
macro body ...
!DOEND
HTH, David
--




On Tue, Oct 25, 2011 at 3:16 PM, Carlos Renato [via SPSSX Discussion]
<[hidden email]> wrote:

> Dear partners
>      Thanks for all suggestions. Finally, the whole question is this set
> of concatenate and put
> quotation marks at the right time.Although simple, it sometimes leaves
> us stuck at work.
> DEFINE makedir (path !CMDEND ).
> HOST COMMAND = [ !QUOTE(!CONCAT("MKDIR ",!path) ) ] .
> !ENDDEFINE .
> makedir path=Path1 Path2.
> Tested and approved.
> The problem was solved. Very much thanks to:
> Albert-Jan Roskam, Bruce Weaver, David Marso, Jon Peck, Art Kendall and
> others
> that help me.
> Carlos Renato
> Statistician - Brazil
> skype: estatistico.org
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://spssx-discussion.1045642.n5.nabble.com/Creating-computer-directories-using-macro-arguments-tp4932558p4937393.html
> To unsubscribe from Creating computer directories using macro arguments,
> click here.
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: Creating computer directories using macro arguments

John F Hall
In reply to this post by Carlos Renato

For basic management and analysis of data from questionnaire surveys and similar rectangular matrices, check out the 400+ pages of (mainly syntax-based) SPSS tutorials on my website.  There’s a summary guide on http://surveyresearch.weebly.com/summary-guide-to-spss-tutorials.html

 

John F Hall

 

[hidden email]

www.surveyresearch.weebly.com

 

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Carlos Renato dos Santos
Sent: 25 October 2011 15:39
To: [hidden email]
Subject: Re: Creating computer directories using macro arguments

 

Dear friends of list

 

     In mid-2006 participated more actively in this list where I learned a lot. 

Now at the end of 2011 I am returning to study problems of manipulation in SPSS

and unfortunately, despite this simpleproblem, I'm not getting resolved. 

I am grateful for every contribution you can at least guide my thinking. Thank you.

 

Carlos Renato

Statistician - Brazil

Reply | Threaded
Open this post in threaded view
|

Automatic reply: Creating computer directories using macro arguments

Buhi, Eric
Banned User
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Creating computer directories using macro arguments

Carlos Renato
In reply to this post by John F Hall
John Hall

Thanks for suggestion.

Carlos Renato