HP3000-L Archives

June 1998, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Glenn Cole <[log in to unmask]>
Reply To:
Date:
Thu, 25 Jun 1998 08:45:24 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (112 lines)
Item Subject: Re: [HP3000-L] Check DDS tape
Tony Peters writes:

> There are probably better ways of doing this but it works.
[snip]
> !FILE TAPEF;MSG;REC=-80,,F,ASCII;SAVE
> !SHOWDEV DAT >>*TAPEF
> !WHILE FINFO("TAPEF",'EOF') > 0
> !  INPUT REC < TAPEF
> !  IF ![POS("(W)","!REC")]>0 THEN
> !     SETVAR TAPEOK "YES"
> !  ENDIF
> !ENDWHILE

For some reason, I always got hung up on counting the number of
records in a msg file, then reading no more than that number.
I like this technique better.

I wondered how this could be made easier, specifically without
using a MSG file.

(The following examples assume NO file equation for tapef.)

Robelle's Qedit came to mind first.  That is, you could use something like

        !showdev DAT > tapef
        !run qedit.pub.robelle; parm=4; info='list tapef "(W)"'
        !if qeditcount > 0
        !   setvar tapeok  "YES"
        !else
        !   setvar tapeok  "NO"
        !endif

And if you have MPEX, some variant of

        %print tapef; search="(W)"

would likely work as well.

While I hope both of these products are on most systems, they're
not bundled with FOS.

'grep' is one of a family of search tools bundled with POSIX.
However, since POSIX does not "see" MPE temp files, we have to
work only on permanent files:

        !purge         tapef
        !showdev DAT > tapef
        !save          tapef
        !
        !grep.hpbin.sys '"(W)" TAPEF > TAPERSLT'
or
        !grep.hpbin.sys '"(W)" TAPEF' > TAPERSLT

In the first case, with "> TAPERSLT" inside the parm to grep,
TAPERSLT will be a bytestream file, saved as a permanent file.
In the second case, outside the quotes, it will be a "normal"
MPE file, saved as a temp file.

In each case, it will contain those lines (if any) from TAPEF
that contain our search string "(W)".  The real difference is
in how finfo() works.

On a bytestream file, finfo( filename,"eof" ) returns the number
of *bytes* in the file.  Of course, for MPE files, it returns
the number of *records*.

Nevertheless, all we care about is whether the file is empty or not.

        !if finfo( "TAPERSLT","eof" )  >  0
        !   setvar tapeok  "YES"
        !else
        !   setvar tapeok  "NO"
        !endif

'grep' also returns a status:  zero (0) means the string was found,
non-zero means it was not (for whatever reason).  I thought this status
was retained only in the POSIX shell, but it looks like I was wrong.
It appears that this status is kept in the jcw CJCW.  So, rather than
worry about whether you're counting bytes or records, you can use the
following instead of the finfo() code above:

        !if cjcw = 0
        !   setvar tapeok  "YES"
        !else
        !   setvar tapeok  "NO"
        !endif

That means we don't need TAPERSLT:

        !grep.hpbin.sys '"(W)" TAPEF' > $NULL

Note that the redirection is *outside* the quoted parm to grep!
If we put it inside the quotes, then POSIX would have to know about
$NULL, and it doesn't.  The UNIX convention of /dev/null does not
work either (although it *does* work if you're actually in the shell).


Mind you, I'm not suggesting that existing message-file code
be yanked out and replaced with something else; I was just
looking for alternatives.  (Personally, I prefer the QEDIT solution.)

FWIW.

--Glenn Cole
  Software al dente, Inc.
  [log in to unmask]

.......................................................................

Item Subject: cc:Mail Text

ATOM RSS1 RSS2