!
! RLOGIN.BAS - Get and display current login without using XCALLS.
!
! Written by Stephen Caldwell CALD/AM 16-jul-88  (213) 947-3771.
!
! As usual, any AMUS member is welcome to it.
!
!
map1 RDISK,S,6
map1 RPPN,S,9

program RLOGIN,1.0A(100)

START: JCB=65536*word(1052)+word(1054)         ! Job Control Block.

      N=word(JCB+52)                          ! Get device name(DSK,HWK).

      call UPKR50                             ! Unpack RAD50.

      RDISK=A$+str(word(JCB+54))+":"          ! Save device name and number
                                              ! and stick a ":" on the end.
      N=int(word(JCB+20)/256)                 ! Get project and programmer
      A=int(word(JCB+20))-256*N               ! numbers in octal.

      call OCTCVT                             ! Convert "N" to decimal.

      PPN1$="["+A$+","                        ! Save decimal project number.
      N=A                                     ! Shlop octal programmer
                                              ! number into "N".
      call OCTCVT                             ! Convert "N" to decimal.

      RPPN=PPN1$+A$+"]"                       ! Put [P,PN] together.

      ? "Current login: "; &
              tab(-1,12);RDISK;RPPN           ! Display complete login.

EXIT:  END
!----------------------------------------------------------------------------
!!
! Unpack RAD50 values.
!!
UPKR50:
      A$=chr(0)

      A=int(N/1600)
      call UPK1

      A=int((N-1600*A)/40)
      call UPK1

      A=N-40*int(N/40)

UPK1:  A$=A$+" ABCDEFGHIJKLMNOPQRSTUVWXYZ$.%0123456789"[A+1;1]

      return

!!
! Convert value in N to octal format in A$.
!!
OCTCVT:
      A$=chr(0)
      DIGPOS=64
      ZFLAG=0

OC1:   DIGVAL=0

OC2:   if DIGPOS<=N then &
              DIGVAL=DIGVAL+1: &
                      N=N-DIGPOS: &
                              goto OC2

      if DIGVAL>0 or ZFLAG>0 or DIGPOS=1 then &
              A$=A$+str(DIGVAL): &
                      ZFLAG=1

      DIGPOS=DIGPOS/8

      if DIGPOS=>1 then &
              goto OC1

      return