View previous topic :: View next topic
|
Author |
Message |
Patrick McGhee
New User
Joined: 10 Mar 2008 Posts: 3 Location: USA
|
|
|
|
Hello everybody! Thanks for all the help and insight that I have taken from this site to date.
I'm having a difficult time trying to parse a server path string into variables for each folder. I am running into problems where there is a space in the folder name.
For instance: I would like to take \\root\name 1\name 2\name 3 and store each folder name into a variable like this:
fname1 = root
fname2 = name 1
fname3 = name 2
fname4 = name 3
Here is the code that I am working with:
Code: |
/* REXX */
Parse Upper Arg path .
slash = '\'
parse value path with (slash) fname0 (slash) fname1 (slash) fname2,
(slash) fname3 (slash) fname4 (slash) fname5 (slash) fname6,
(slash) fname7 (slash) fname8 (slash) fname9 (slash)
say fname0
say fname1
say fname2
say fname3
say fname4
say fname5
|
With input as:
Code: |
\\ROOT\WRKGRP\IT DEVELOPMENT\_INDIVIDUAL FOLDERS
|
Here is my Ouput:
Code: |
READY
%TESTREXX \\ROOT\WRKGRP\IT DEVELOPMENT\_INDIVIDUAL FOLDERS
ROOT
WRKGRP
IT
|
Any help would be greatly appreciated.
Man I hope I didn't break any forums rules on my first post!
Thanks,
Patrick |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
it' s not the rexx that is not working,
it' s the invocation format that' s wrong
the tokn You are trying to pass is being resolved as two parameters
IIRC try quoting the invocation parameter
but as a general consideration it is not a safe practice to have path names with embedded blanks |
|
Back to top |
|
|
Patrick McGhee
New User
Joined: 10 Mar 2008 Posts: 3 Location: USA
|
|
|
|
Thank you for the quick reply!
Although I didn't recognize it a first I understand what you are saying. However, even if I put the string in quotes it resolves to the same thing. I am invoking REXX through batch JCL passing in the path name. I would like to pass it in through the JCL to keep from hard-coding it in the REXX.
I understand the complexities with spaces in folder path names but this is something that cannot change. There are spaces in the folder names on our production servers so we have to code for it.
Thanks again,
Patrick |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
Remove the dot at the end of
Parse Upper Arg path . |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Patrick and welcome to the forums,
You might try something i'd call a pseudo-blank - a keyboard character that would not ever appear in the string, and would be replaced by an x'40' after the string was broken into the component fields. Things like ~ | ! come to mind as they aren't as likely to be used in designed folder names (seen a few of these that were system generated, but not admin-designed). |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
also, I question the use of UPPER in the parse statement. I think it is case sensitive. |
|
Back to top |
|
|
Ramya A
Active User
Joined: 26 Jul 2004 Posts: 104
|
|
|
|
Hi Patrick,
I just tried your code and it worked fine for me:
Code: |
/* REXX */
say "Enter path name"
pull path
slash = '\'
parse value path with (slash) fname0 (slash) fname1 (slash) fname2,
(slash) fname3 (slash) fname4 (slash) fname5 (slash) fname6,
(slash) fname7 (slash) fname8 (slash) fname9 (slash)
say fname0
say fname1
say fname2
say fname3
say fname4
say fname5 |
When I executed the above code, I got:
Code: |
Enter path name
\\ROOT\WRKGRP\IT DEVELOPMENT\_INDIVIDUAL FOLDERS
ROOT
WRKGRP
IT DEVELOPMENT
_INDIVIDUAL FOLDERS
*** |
|
|
Back to top |
|
|
Patrick McGhee
New User
Joined: 10 Mar 2008 Posts: 3 Location: USA
|
|
|
|
Thanks for all of your help guys!
Pedro,
The REXX invokation worked and parsed correctly when I removed the period from the parse sentence.
Dick,
This method would have been my fallback. Thanks!
Ramya,
I did not try your solution of using the pull method. This would have probably satisfied my needs as well.
Very knowledgeable group of guys here!
Thanks again.
Patrick |
|
Back to top |
|
|
|