From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 10-SEP-1989 08:47
To:	MRGATE::"ARISIA::EVERHART"
Subj:	re: re: Generating unique member UIC's

Message-Id:  <8909101241.AA20670@crdgw1.ge.com>
Received: From CUNYVM.CUNY.EDU by CRVAX.SRI.COM with TCP; Sat,  9 SEP 89 20:54:03 PDT
Received: from UALR.BITNET by CUNYVM.CUNY.EDU (IBM VM SMTP R1.2.1MX) with BSMTP id 0414; Sat, 09 Sep 89 23:54:45 EDT
Date: Sat, 9 Sep 89 22:53 CST
From: Dale Miller <DOMILLER%UALR.BITNET@CUNYVM.CUNY.EDU>
Subject: re: re: Generating unique member UIC's
To: info-vax@kl.sri.com
X-Vms-To: IN%"info-vax@kl.sri.com"

I wish to stand corrected (but only slightly chastised).

I wrote:

> [...] There is NOT a straightforward way to do this in DCL since you can't
> do a read on a binary key [...].
The preceding sentence was based on the VMS HELP entry:

READ
  /KEY
   /KEY=string
   Requests that a record  having  a  key  that  matches  the  specified
    character  string be read.  Binary and integer keys are not allowed.

However, Wolfgang J. Moeller (U0012@DGOGWDG5.BITNET) responded with an
interesting note that I have included to show everyone the trouble that one can
get into by READING the documentation.

>I admit that it is truly not straightforward, but you CAN read on a binary key!
>(I discovered that device when once I had to "$REPLY" an arbitrary text,
>containing any number of single and double quotes.)
>Here goes (your FORTRAN program in DCL, translated almost literally) ...
>
>$ if f$type(p1).nes."INTEGER" then exit 0
>$ group='p1'
>$!
>$ open/read/share UAF$ 'f$parse("SYSUAF","SYS$SYSTEM:.DAT")'
>$!
>$ uic=group*%x10000
>$10:
>$ key="****"
>$ key[0,32]=uic
>$!=============== start of wierd section ======================================
>$! "&" recognizes quotation marks, so they must be quoted & doubled ...
>$ if f$loc("""",key).eq.f$len(key) then goto qq_ok      ! ... unless none there
>$ iqq=0
>$ sqq=""
>$qq_loop:
>$ sqq1=f$elem(iqq,"""",key)
>$ if sqq1.eqs."""" then goto qq_loop_end
>$ sqq=sqq+""""+sqq1+""""
>$ iqq=iqq+1
>$ goto qq_loop
>$qq_loop_end:
>$ key=sqq
>$qq_ok:
>$!=============== end of wierd section ========================================
>$!
>$ read/ind=1/key=&key/mat=eq/err=200 UAF$ uaf_first
>$ uic = uic + 1
>$ if (uic.and.%xFFFF).le.%o177776 then goto 10
>$ write SYS$OUTPUT f$fao("No members available in group !OW",group)
>$ close UAF$
>$ exit 42
>$!
>$200:
>$ write SYS$OUTPUT f$fao("The first available member in group !OW is !OW",-
>                        group,(uic.and.%xFFFF))
>$ next_mem==f$fao("!OW",(uic.and.%xFFFF))
>$ close UAF$
>$ exit 1
>
>Enjoy!
>
>Wolfgang J. Moeller, GWDG, D-3400 Goettingen, F.R.Germany | Disclaimer ...
>Bitnet/Earn: U0012@DGOGWDG5         Phone: +49 551 201516 | No claim intended

--------------------------------------------------------------------------
| Dale O. Miller                        | #   #  ###  #     ####         |
| University of Arkansas at Little Rock | #   # #   # #     #   #        |
| 2801 S. University                    | #   # ##### #     ####         |
| Little Rock, AR  72204-1099  USA      | #   # #   # #     #  #         |
| (501)569-8714                         |  ###  #   # ##### #   #        |
| DOMILLER@UALR.BITNET                  | Disclaimer: This does not      |
| 92-20-28 W,34-43-30 N.ICBMNET         | say what I say it doesn't say. |
--------------------------------------------------------------------------

