Operating System - OpenVMS
1828040 Members
2034 Online
109973 Solutions
New Discussion

wildcard expressions in DCL script

 
SOLVED
Go to solution
Tim Nelson
Honored Contributor

wildcard expressions in DCL script

Having trouble finding this easy one.
if var .eqs. "bob*" then goto A

Looking to use wildcard in an if statement.

Thanks in advance.
11 REPLIES 11
Antoniov.
Honored Contributor

Re: wildcard expressions in DCL script

Hi Tim,
wildcard works only with files (command DIR or lex F$SEARCH).
I wrote a C routine to manage LIKE operator; if you have a C compiler I can send you source code.

Bye
Antoniov
Antonio Maria Vigliotti
labadie_1
Honored Contributor

Re: wildcard expressions in DCL script

if you want to do that, I think you have better options than the Dcl
- Perl for Vms
http://www.sidhe.org/vmsperl/
- awk (in Tcpip examples, snmp subdirectory, you have gawk)
- Python for Vms
vmspython.dyndns.org

all have regular expression matching, in python
import re
re.compile...
Tim Nelson
Honored Contributor

Re: wildcard expressions in DCL script

Thanks for the tips.. I was hoping I would not have to install / use another application.
I did the following to get what I wanted.

if f$extract(0,3,VAR) .eqs. "BOB" then goto

better than nothing and works..

Much appreciative.
Antoniov.
Honored Contributor

Re: wildcard expressions in DCL script

Tim,
load this simple like routine written in DCL. It's very simple but can help you.

Bye
Antoniov
Antonio Maria Vigliotti
Hein van den Heuvel
Honored Contributor
Solution

Re: wildcard expressions in DCL script


Your extract and compare is the classic solution, but the most rigid as the string must be in an exact location.

Most folks will use F$LOCATE comparing the result with F$LENGTH to get at the "*string" leading wildcard effect.

There are also creative usages of F$ELEMENT for stirng locating.

And there is yet an other, not too well known, method to check for string matches in DCL through string subtraction (reduction)!

$ test = "xxxxABCyyyy"
$ if test .eqs. (test - "ABC") then write sys$output "Not found"
$ if test .eqs. (test - "ABCD") then write sys$output "Not found"
Not found
$ x = test - "ABC"
$ show symb x
X = "xxxxyyyy"
$

Here is an other (a bit more widespread used)string subtract example:

$ write sys$output f$cvt() -
-" "-"-"-"-"-":"-":"-":"-"."
2004012911245313

Enjoy!
Hein.




Antoniov.
Honored Contributor

Re: wildcard expressions in DCL script

...and if you need somthing better I can compile the prior example for you.

Bye
Antoniov
Antonio Maria Vigliotti
Tim Nelson
Honored Contributor

Re: wildcard expressions in DCL script

All excellent options !!!

Thanks to everyone.
John Eerenberg
Valued Contributor

Re: wildcard expressions in DCL script

fwiw
a variation on
$ if f$extract(0,3,VAR) .eqs. "BOB" then goto A
would be
$ var=f$edit(var,"trim,compress,upcase")
$ if f$extract(0,3,VAR) .eqs. "BOB" then goto A
this gives me a level of predictability when it comes to leading spaces, multiple space/tabs, and upper/lower case.
hope it helps.
john

It is better to STQ then LDQ
Jan van den Ende
Honored Contributor

Re: wildcard expressions in DCL script

And if you favour to compact it into "one" function, use:

$ if f$extract(0,3,f$edit(var,"trim,compress,upcase") .eqs. "BOB" then goto A
Don't rust yours pelled jacker to fine doll missed aches.
Simon French
New Member

Re: wildcard expressions in DCL script

Hi,

Another thought. How about using f$locate..

$ aa = "****BOB###"
$ bb = f$locate("BOB",aa)
$ sh symb bb
BB = 4 Hex = 00000004 Octal = 00000000004
$ bb = f$locate("BILL",aa)
$ sh symb bb
BB = 10 Hex = 0000000A Octal = 00000000012
$

The result being the string location if found, else its length if not found.

Regards
Simon
Semper in Excernere
Ian Miller.
Honored Contributor

Re: wildcard expressions in DCL script

See also
http://www.openvms.org/stories.php?story=03/03/31/6547431
____________________
Purely Personal Opinion