From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  9-SEP-1989 00:28
To:	MRGATE::"ARISIA::EVERHART"
Subj:	RE: Generating unique member UIC's

Message-Id:  <8909090423.AA08590@crdgw1.ge.com>
Received: From CUNYVM.CUNY.EDU by CRVAX.SRI.COM with TCP; Fri,  8 SEP 89 20:53:59 PDT
Received: from UALR.BITNET by CUNYVM.CUNY.EDU (IBM VM SMTP R1.2.1MX) with BSMTP id 6384; Fri, 08 Sep 89 23:54:39 EDT
Date: Fri, 8 Sep 89 22:53 CST
From: Dale Miller <DOMILLER%UALR.BITNET@CUNYVM.CUNY.EDU>
Subject: RE: Generating unique member UIC's
To: INFO-VAX@KL.SRI.COM
X-Vms-To: IN%"INFO-VAX@KL.SRI.COM"

  Mark Urban-Lurain  (urban@cpswh.cps.msu.edu) writes:
>I'm writing a DCL batch job to create a large number of accounts
>for students at the beginning of each term and would like a way
>to generate a unique member UIC for each ID.  All the students
>for a given course are in the same group, so that part of the UIC
>is not a problem.  However, we'd like to have a unique member
>UIC for each account.
>
>Is there a straightforward way to get the next available member
>UIC for any group in DCL?  (We're running VMS 4.6.)
>
>E-mail's fine and I'll summarize, unless you think this is of
>general interest.
>
>Thanks.
>Mark Urban-Lurain                        urban@cpswh.cps.msu.edu
>Computer Science Dept.                   urbanluraimg@clvax1.cl.msu.edu
>Michigan State University
>A-714 Wells Hall                         (517) 353-0682   office
>East Lansing, MI     48824               (517) 355-5210   department

Being the outspoken person I am, I think it's of general interest.  There is
NOT a straightforward way to do this in DCL since you can't do a read on a
binary key and that's the only way to access SYSUAF.  However, a program which
can be defined as a foreign command and returns a value in a symbol is fairly
easy to come up with.  FORTRAN code follows:
        implicit none
        integer*4   uic,strlen
        integer*2   group,member
        character   uaf_first*36,octstr*6

 1001   format(o<strlen>)
 1002   format(' No members available in group ',o6)
 1003   format(' The first available member in group ',o6,' is ',o6)
 1004   format(o6.6)
        call lib$get_foreign(octstr,'Group? ',strlen)
        if(strlen.eq.0) call exit
        read(octstr(1:strlen),1001,err=900)group

        open(unit=10, file='SYS$SYSTEM:SYSUAF.DAT',shared,
        1   access='keyed',organization='indexed',status='old')

        uic = group*2**16

 0010   read(10,key=uic,err=200,keyid=1) uaf_first
        uic = uic + 1
        if((uic.and.'ffff'x).gt.'177776'o) then
            write(*,1002)group
            call exit(42)
            end if
        go to 10
 0200   write(*,1003)group,(uic.and.'ffff'x)
        write(octstr,1004)(uic.and.'ffff'x)
        call lib$set_symbol ('NEXT_MEM', octstr,)
        call exit

 0900   write(*,*) 'Invalid group entered'
        end


--------------------------------------------------------------------------
| 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. |
--------------------------------------------------------------------------

