1822894 Members
3632 Online
109645 Solutions
New Discussion юеВ

F$PARSE

 
SOLVED
Go to solution
FOX MULDER_2
Frequent Advisor

F$PARSE

Hi,
I need to return the highest version number of a file.
I tried using
$ SPEC = F$PARSE("INFO.COM",,,"VERSION",""SYNTAX_ONLY"")
$ sh sym spec

The return value is ";" only.

Can anyone please let me know how to obtain the highest version of a file using F$PARSE.

Thnaks
10 REPLIES 10
John Abbott_2
Esteemed Contributor
Solution

Re: F$PARSE

How's about

$SPEC =
F$PARSE(F$SEARCH("INFO.COM;"),,,"VERSION")-";"

J.
Don't do what Donny Dont does
Steven Schweda
Honored Contributor

Re: F$PARSE

If you want real information about real
files, remove the "SYNTAX_ONLY".

LEXICALS
F$PARSE
Arguments
parse-type
[...]
SYNTAX_ The syntax of the file specification is checked
ONLY without verifying that the specified directory exists
on the specified device.
Jon Pinkley
Honored Contributor

Re: F$PARSE

F$PARSE will not return the version by looking at the file, it is parsing the filespec and supplying defaults.

$ dir sys$login:login.com;

Directory ROOT$USERS:[JON]

LOGIN.COM;231

Total of 1 file.
$ write sys$output f$parse("sys$login:login.com;",,,"VERSION")
;
$

John Abbott had the correct answer with f$search, which is what actually does directory lookups. Give him points.

it depends
FOX MULDER_2
Frequent Advisor

Re: F$PARSE

Thanks to all for the prompt reply.


Worked in a single shot.

All credits to John.

Thanks again
Hein van den Heuvel
Honored Contributor

Re: F$PARSE

Actually... it looks like this might be broken.

Seems like too big a bug to be but still.
I tried on OpenVMS 7.2-1 and 8.3

An 'ask the wizard' article on this avoids the question:
http://h71000.www7.hp.com/wizard/wiz_9147.html

The only working examples I see are effectively using:

F$PARSE(F$SEARCH(file...),,,"VERSION")
In that case obviously the "SYNTAX_ONLY" does no harm and can be recommended.

btw... why the double-double-quotes?
Act of desperation?

So for now i would recommend
$ SPEC = F$PARSE("INFO.COM",,,"VERSION",""SYNTAX_ONLY"")

Hope this helps some,
Hein van den Heuvel (at gmail dot com)
HvdH Performance Consulting
FOX MULDER_2
Frequent Advisor

Re: F$PARSE

As I have found the solution,I am closing the thread.

Thnaks to all.
Hein van den Heuvel
Honored Contributor

Re: F$PARSE

Not broken of course.
Functionning as designed.
Got side-tracked.

Parse is supposed to do just that: look at pieces of string.

It should NOT look up the file.
F$SEARCH will do that.

Sorry if I confused anyone.

Hein.

Jess Goodman
Esteemed Contributor

Re: F$PARSE

I recently ran into an interesting undocumented "feature" of F$PARSE. If you use the "field" argument then a SYNTAX_ONLY parse is always done. I.E. if you ask for only one part of the filespec to be returned then F$PARSE never verifies that the device/directory exists.

$ say f$parse("DISK:[NOEXIST]JUNK.DAT",,,,"SYNTAX_ONLY")
DISK:[NOEXIST]JUNK.DAT;
$ say f$parse("DISK:[NOEXIST]JUNK.DAT",,,,)

$ say f$parse("DISK:[NOEXIST]JUNK.DAT",,,"DEVICE",)
DISK:
$ say f$parse("DISK:[NOEXIST]JUNK.DAT",,,"DIRECTORY",)
[NOEXIST]
$ say f$parse("DISK:[NOEXIST]JUNK.DAT",,,"NAME",)
JUNK
I have one, but it's personal.
EdgarZamora
Trusted Contributor

Re: F$PARSE

The HELP message does state that it won't verify the directory if a field is specified. It doesn't mention device, filename, etc. but I guess it applies to those too, if a field is specified.

"By default, the F$PARSE function verifies that the directory in the file specification exists on the device in the file specification; however, the existence of the directory is not verified if you provide a field argument."

John Abbott_2
Esteemed Contributor

Re: F$PARSE

PS...

You can wrap it in F$INTEGER to return the value as as a numeric symbol rather than a string

Eg.

$SPEC =
F$INTEGER(F$PARSE(F$SEARCH("INFO.COM;"),,,"VERSION")-";")

J.
Don't do what Donny Dont does