From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 26-AUG-1989 14:30
To:	MRGATE::"ARISIA::EVERHART"
Subj:	RE: searching directories for the excistance of files

Received: From RELAY.CS.NET by CRVAX.SRI.COM with TCP; Sat, 26 AUG 89 10:39:11 PDT
Received: from crdgw1.ge.com by RELAY.CS.NET id aa22535; 26 Aug 89 13:39 EDT
Received:  by crdgw1.ge.com (5.57/Ultrix 3.0 (1.51))
	 id AA18090; Sat, 26 Aug 89 13:40:52 EDT
Message-Id:  <8908261740.AA18090@crdgw1.ge.com>
Date: 26 Aug 89 13:33 EST
From: SESSIONS%SPAREV.DECNET@crdgw1
Subject: RE: searching directories for the excistance of files
To: info-vax%CRVAX.SRI.COM@RELAY.CS.NET

>Message-Id: <17583@ut-emx.UUCP>
>From: usc!cs.utexas.edu!ut-emx!mike@apple.com  (Mike O'Donnell)
>
> I am interested in obtaining some sample source code to
> check a directory for the existence of certain files.  What
> I wish to do is look in one particular directory and see if
> any files match a VMS wildcard specification.  That is, I
> would like code that given the wildcard "*.LST;*" would 
> return (perhaps one-by-one) the list of files that match.
> Preferably the code is in C or Fortran.
>
> Thanks, Mike O'Donnell

Here is a snippet of FORTRAN code which displays the names of file
matching the wildcard specification. You should be able to modify
it to suit your needs.

c
c	wild.for
c
c	this vax fortran program illustrates how to use "wild carding"
c	in a program. this program executes the equivalent to the DCL
c	command "dir/nohead/notrail sys$login:*.*;*". This function
c	can also be done at the DCL level in a command procedure with
c	the f$search lexical function. Shouldn't be too hard to
c	convert it to a subroutine
c
c
	program		wild
	implicit	none
	include		'($syssrvnam)'
	include		'($rmsdef)'
	include		'($namdef)'
	include		'($fabdef)'
	integer*4	lib$signal
	record		/namdef/	name
	record		/fabdef/	fab
	character*255	inp_str,
	1		res_str,
	1		exp_str
	byte		inp_str_len
	integer*4	status
	fab.fab$b_bid = fab$c_bid
	fab.fab$b_bln = fab$c_bln
	fab.fab$l_fop = fab.fab$l_fop .or. fab$m_nam
	fab.fab$l_nam = %loc(name)
	fab.fab$l_fna = %loc(inp_str)
	name.nam$b_bid = nam$c_bid
	name.nam$b_bln = nam$c_bln
	name.nam$l_rsa = %loc(res_str)
	name.nam$b_rss = nam$c_maxrss
	name.nam$l_esa = %loc(exp_str)
	name.nam$b_ess = nam$c_maxrss
c
c	change the following assignment for different
c	directory/wildcard
c
	inp_str = '[...]*.*;*'
	inp_str_len = 15
	fab.fab$b_fns = inp_str_len
	status = sys$parse(fab,,)
	if(status.ne.rms$_normal) call lib$signal(%val(status))
200	status = sys$search(fab,,)
	if(status.eq.rms$_nmf) call exit
	if(status.ne.rms$_normal) call lib$signal(%val(status))
c
c	here is the output, change this if you need to return
c	the value from subroutine
c
	type *,res_str(1:name.nam$b_rsl)
	goto 200
	end

Zack C. Sessions                         Sessions%Sparev.decnet@crd.ge.com
General Electric Corporation             Sessions@sparev.ge.com (UUCP Zone)
Wilmington, NC USA                       (919) 675-5517
"If you ain't the lead dog, the view never changes."

