home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.vms
- Path: sparky!uunet!gatech!darwin.sura.net!jvnc.net!yale.edu!news.yale.edu!neutron!dcs
- From: dcs@neutron.chem.yale.edu (Dave Schweisguth)
- Subject: Anyone want to neaten this up? (DCL exercise)
- Message-ID: <1992Aug20.200921.122@news.yale.edu>
- Sender: news@news.yale.edu (USENET News System)
- Nntp-Posting-Host: neutron.chem.yale.edu
- Organization: Yale University
- X-Newsreader: Tin 1.1 PL4
- Date: Thu, 20 Aug 1992 20:09:21 GMT
- Lines: 70
-
- Hi all,
-
- I have here this little FORTRAN data-munging program ("f2a") which reads from
- FOR005 and writes to FOR006. I used to use a little script wrapper that did the
- assigns and ran the program once and that was that. I just got ambitious and
- wrote a new wrapper that deals with wildcards and multiple targets on the
- command line. It works fine so far. OTOH, it's awful scruffy-looking and I
- would not be at all surprised to find that there are better ways to do some of
- these things. Perhaps some of you DCL gurus would find this entertaining.
-
- Well, here are some of the things that bother _me_:
-
- - If I feed this, say "file.*", meaning to run "f2a" on file.001, file.002,
- etc., I'll get file.001a, file.002a, etc. as output. (Mind you, I do need
- those names.) F$SEARCH will also pick up the output files, so I have to have
- an extra loop where I read all the source file names in before I run "f2a"
- the first time.
-
- - If I feed this just "file.001", f$search will spit back the same single
- file over and over, so I have to have this "old_target" check.
-
- - The string of F$PARSEs is really ugly. Any way to just delete the version?
-
- Note that I can't really test the input files to see if they're legal before
- running "f2a", since they're just unformatted binary data and this will be
- running in an environment where there will be other unformatted binary files
- that will make "f2a" cough up a lung ... thus the "on error" business.
-
- OK, here it is:
-
- $ pcount = 1
- $ ploop: if p'pcount' .eqs. "" then exit
- $ targets = 0
- $ old_target := none
- $ sloop: target = f$search(p'pcount',1)
- $ if target .nes. "" .and. target .nes. old_target
- $ then
- $ targets = targets + 1
- $ target'targets' = target
- $ old_target = target
- $ goto sloop
- $ endif
- $ tcount = 0
- $ tloop: if tcount .lt. targets
- $ then
- $ tcount = tcount + 1
- $ target = target'tcount'
- $ targeta = f$parse(target,,,"device") + -
- f$parse(target,,,"directory") + f$parse(target,,,"name") + -
- f$parse(target,,,"type") + "a"
- $ assign /nolog 'target' for005
- $ assign /nolog 'targeta' for006
- $ on error then gosub clean ! can't stop Joe User from feeding in
- $ run f2a ! a bad file in the first place ...
- $ on error then exit
- $ goto tloop
- $ endif
- $ pcount = pcount + 1
- $ goto ploop
- $ clean: dead_meat = f$search(targeta)
- $ if dead_meat .nes. "" then delete 'dead_meat'
- $ return
-
- Mail would be fine; I'll summarize anything interesting.
-
- Cheers,
-
- --
- | Dave Schweisguth Yale MB&B & Chemistry Email: dcs@neutron.chem.yale.edu |
- | Lab phone: 203-432-5208 Fax: 203-432-6144 Home phone: 203-624-3866 |
-