- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: Checking if filename contains a directory spec...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2007 11:13 AM
тАО04-05-2007 11:13 AM
I would like to use it to determine if an input parameter include a device or directory if not then it will look in a default directory defined by some logical name.
Thanks
J Bath
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2007 12:07 PM
тАО04-05-2007 12:07 PM
Solutionwith an unlikely default file specification:
$ ws = "WRITE SYS$OUTPUT"
$ f = f$edit(p1,"COLLAPSE,UPCASE")
$ nsdev = "NO_SUCH_DEV:"
$ nsdir = "[no_such_dir]"
$ nsdevdir = nsdev+ nsdir
$ dev = f$parse( f, nsdevdir, , "DEVICE", "SYNTAX_ONLY")
$ dir = f$parse( f, nsdevdir, , "DIRECTORY", "SYNTAX_ONLY")
$ if (dev .eqs. nsdev)
$ then
$ dev = "(none)"
$ endif
$ ws "Device = ''dev'"
$ if (dir .eqs. nsdir)
$ then
$ dir = "(none)"
$ endif
$ ws "Directory = ''dir'"
$!
But it may be that you could simply use
F$PARSE with your logical name as the default
file spec.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2007 03:33 PM
тАО04-05-2007 03:33 PM
Re: Checking if filename contains a directory specification
Can we safely ignore ODS-5 extended file naming?
If not then you really should go the F$PARSE route. Else, You could just do
$test = f - "]" - ">" - ":"
$if test.nes.t then ws "Device or Directory present".
But I would like to echo Steven's closing suggestion: Just let F$PARSE do all the work. Let it combine the filespec with the missing pieces provided as 'default name'.
That's what it is there for.
Now if you wanted to do this in a program, not DCL, and wanted to roll your own, then you should look at the $FILESCAN system service.
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2007 10:09 PM
тАО04-05-2007 10:09 PM
Re: Checking if filename contains a directory specification
Please use the F$PARSE lexical function. It is guaranteed to work (you can limit the processing as noted by using the SYNTAX_ONLY parameter).
You can also use multi-level defaulting when using F$PARSE. This allows you to specify default elements (e.g. logical names, directories) for things in a manner consistent with all of the other system utilities.
It is NEVER recommended to parse things yourself. On occasion, changes appear that can break manual filename parsing (e.g. ODS-5). The lexical function is guaranteed to work correctly. Manual code is guaranteed to have to be maintained over the years.
A good general rule is that it is worth the time and effort to use a provided facility (e.g. F$PARSE) than to write one's own code.
- Bob Gezelter, http://www.rlgsc.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 12:56 AM
тАО04-06-2007 12:56 AM
Re: Checking if filename contains a directory specification
$ IF F$PARSE(P1,"BOGUS:[BOGUS]",,,) .EQS. "" THEN WRITE SYS$OUTPUT "INVALID"
Change BOGUS to something else if BOGUS is a valid device/dir at your place.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 01:17 AM
тАО04-06-2007 01:17 AM
Re: Checking if filename contains a directory specification
That will not work if filespec does provide a device or directory, but one which is not valid (yet).
It will also return a blank string.
The question was:
" Checking if filename contains a directory specification"
It did not indicate whether that directory needed to be valid, allthough admittedly that typically is expected.
- the final file spec may need to be use in a different context, maybe a different system.
- the file, directory or logical name for the device might not yet exist
Agreed, unlikely.
I normally solve it like Steven already suggested.
Provide a recognizable bogus directory / device as default name and see if they come back after a SYNTAX_ONLY' parse.
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 01:34 AM
тАО04-06-2007 01:34 AM
Re: Checking if filename contains a directory specification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 02:31 AM
тАО04-06-2007 02:31 AM
Re: Checking if filename contains a directory specification
It isn't trivial to get all the cases, and the effort becomes increasing non-trivial when the potential exists for changes in the parsing rules in future releases.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 03:40 AM
тАО04-06-2007 03:40 AM
Re: Checking if filename contains a directory specification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 05:25 AM
тАО04-06-2007 05:25 AM
Re: Checking if filename contains a directory specification
please review
http://forums1.itrc.hp.com/service/forums/helptips.do?#33
on how to express thanks in these forums.
Proost.
Have one on me.
jpe