IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Parse a folder path, seperating by each folder


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Patrick McGhee

New User


Joined: 10 Mar 2008
Posts: 3
Location: USA

PostPosted: Wed May 14, 2008 10:20 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed May 14, 2008 10:37 pm
Reply with quote

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
View user's profile Send private message
Patrick McGhee

New User


Joined: 10 Mar 2008
Posts: 3
Location: USA

PostPosted: Thu May 15, 2008 1:48 am
Reply with quote

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
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Thu May 15, 2008 2:09 am
Reply with quote

Remove the dot at the end of

Parse Upper Arg path .
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu May 15, 2008 2:10 am
Reply with quote

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
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Thu May 15, 2008 2:11 am
Reply with quote

also, I question the use of UPPER in the parse statement. I think it is case sensitive.
Back to top
View user's profile Send private message
Ramya A

Active User


Joined: 26 Jul 2004
Posts: 104

PostPosted: Thu May 15, 2008 2:14 am
Reply with quote

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
View user's profile Send private message
Patrick McGhee

New User


Joined: 10 Mar 2008
Posts: 3
Location: USA

PostPosted: Thu May 15, 2008 5:45 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts SET PATH in View DDL DB2 2
No new posts INREC PARSE used to sort a CSV file DFSORT/ICETOOL 2
No new posts JSON transform using CICS bundles vs.... CICS 3
No new posts JSON PARSE in Enterprise COBOL COBOL Programming 2
Search our Forums:

Back to Top