[comp.os.vms] DCL query -- f$parse

mcwill@prlhp1.prl.philips.co.uk (Iain McWilliams) (04/11/88)

  I wish to use F$PARSE to create a full file spec in a command file, when I
only supply part of the filename as a parameter. The problem arises when the
default spec is to contain a logical symbol set up as a search list ==>

----------------------------------------
$assign [unit],[subsystem],[project] search$path:      !usually in login.com
$full_spec = F$PARSE(p1,"search$path:standard.dat")
$if f$search(full_spec) .nes. "" then write sys$output p1," found"
----------------------------------------

  Under these circumstances, F$PARSE will translate the logical into the first 
element in the search list, so that if the file exists elsewhere in the search
list, F$SEARCH cannot find it.
 
  There is a field "parse-type" which I thought may offer a solution, but it
will stop iterative translation only when it encounters a logical name with the
'concealed' attribute, and that attribute is only valid for an equivalence
string which is a physical device.

 Does anyone have a solution, or has the lexical been changed in any recent
(post 4.5) release

 Any suggestions received with thanks,

-- Iain.

rrk@byuvax.bitnet (04/15/88)

To the best of my knowlege, this can't be done.  If you are calling sys$parse
and sys$search, they store special information in the FAB which deals with
search path logicals.  When you call the f$parse lexical, it throws this
information away and all f$search has to go on is the first translation.
You have to make the parse and search use the same FAB block, and I think
this cannot be done from DCL.  On the other hand, if you can get away without
calling f$parse and only call f$search, f$search calls sys$parse first anyway
and uses the same FAB for its sys$search calls.   Unfortunately, this makes
it impossible to provide filename defaults as f$parse allows you to do.

                                AMMON::RAY

rrk@byuvax.bitnet (04/16/88)

It just occurred to me  ...  there is a way to make it work, but it is very
clumsy.  That is...you make your logical search path be a concealed device
definition:

$ DEFINE/TRANS=CONCEALED SEARCH$PATH DEV1:[DIR1.],DEV2:[DIR2.],DEV3:[DIR3.]

Then, construct your filename to be searched as:

search$path:[000000]filename.ext

Since it is concealed device translation, f$parse doesn't translate the
logical name, leaving it for f$search to properly expand into the search
list.

                                AMMON::RAY

BJH@V3.INFERENCE.COM (Brian Hagerty x 111) (04/21/88)

Answering Iain McWilliams query ...

 > I wish to use F$PARSE to create a full file spec in a command file, when I
 > only supply part of the filename as a parameter. The problem arises when the
 > default spec is to contain a logical symbol set up as a search list [...]

The following code seems to meet your needs:

$ define search$path [unit],[subsystem],[project]
$
$ inquire file "File"
$
$ file = f$parse(file,"standard.dat")
$ name = f$parse(file,,,"name")
$ type = f$parse(file,,,"type")
$ if f$search(file).eqs."" then file = f$search("search$path:''name'''type'")
$
$ if file.nes."" then write sys$output file," found!"
$ exit

$ deck
	Brian Hagerty [sic]		BJH @ V3.INFERENCE.COM
	Network Manager
	Inference Corporation
	Lost Angeles, CA
$ eod!
-------