HP OpenVMS Systemsask the wizard |
The Question is:
I'm having a bit of a problem either with F$SEARCH or symbol substitution. I
want to get the result from F$SEARCH and use it in a command line, where it
needs to be quoted. The filespec I'm passing to F$SEARCH needs to have a
symbol substituted into it. L
et me show you...
VGER> sho sym t
T = 3 Hex = 00000003 Octal = 00000000003
VGER> write sys$output "''F$search("pingtest''t'2.tmp")'"
VGER>
If I substitute F$FAO for F$SEARCH, it looks like the correct filespec is being
generated:
VGER> write sys$output "''F$FAO("pingtest''t'2.tmp")'"
pingtest32.tmp
VGER>
Or if I don't put the whole thing in quotes, it works:
VGER> write sys$output F$search("pingtest''t'2.tmp")
USERS:[BLUEJAY.NETDATA]PINGTEST32.TMP;3
VGER>
Obviously I can work around the problem by assigning the F$SEARCH result to
another symbol before I need to use it in my command line, but that's
inelegant and I feel like I'm missing something important here.
Same thing happens on 7.1-2 Alpha and 7.2 VAX. I tried making the symbol t a
string instead of an integer and got the same result.
The Answer is :
When the quotes get to confusing, consider using string concatenation
instead: "a''b'c" can be replaced be "a" + b + "c". Just one character
more, and more readable IMHO.
You problem is then compounded by having the symbol be an integer.
Two possible solutions:
$ write sys$output "''F$search("test" + f$string(t) + "2.tmp")'"
$tt="''t'"
$ write sys$output "''F$search("test" + tt + "2.tmp")'"
|