HP OpenVMS Systems

ask the wizard
Content starts here

DCL quoting, symbol substitution?

» close window

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")'"
If I substitute F$FAO for F$SEARCH, it looks like the correct filespec is being
VGER> write sys$output "''F$FAO("pingtest''t'2.tmp")'"
Or if I don't put the whole thing in quotes, it works:
VGER> write sys$output F$search("pingtest''t'2.tmp")
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")'"
    $ write sys$output "''F$search("test" + tt + "2.tmp")'"

answer written or last revised on ( 30-JAN-2001 )

» close window