PROGRAM MAKEAA, 85.6(17)

! Create A.A files in each PPn of a logical disk if not found.
!
!  6/17/85 - Created & donated by:  SAN DIEGO BUSINESS RESPONSE
!                                 4248 Adams Ave   S.D, CA  92116
!                               (619) 283-7326
!

! The following DO file can be used in conjunction with MAKEAA.BAS:
!!  $D DSK0:
!!  ; MAKEAA.DO - Uses MAKEAA.RUN to create A.A files in each PPn on a disk
!!  ;           for use by MUFDIT to recover lost UFDs 6/17/85 /kfj.
!!  :T
!!  ;   (Press extra RETURN if no password on OPR: account)
!!  LOG OPR:
!!  :K
!!  DIR =$0[]/K/W:8
!!  RUN MAKEAA
!!  DIRSEQ $0[]/E
!!  DIR $0[]A.A

!       !       !       !       !       !       !       !       !       !

MAP1 DIRECT'FILE        ,S,10,"DIRECT.LST"              !.DIR/W =[] works fine
MAP1 FILENAME           ,S,24
MAP1 INLINE             ,S,255
MAP1 DEVICE             ,S,5
MAP1 LEFT'BRACK         ,F
MAP1 RIGHT'BRACK        ,F
MAP1 TEMP1              ,F

! Variables used in getting system date:
MAP1 DATE'MASK          ,S,2,   "##"                    ! Date mask
MAP1 BDATE              ,B,4                            ! Binary system date
MAP1 BBDATE,@BDATE                                      ! Parts of BDATE
       MAP2 MONTH      ,B,1
       MAP2 DAY        ,B,1
       MAP2 YEAR       ,B,1
MAP1 DAT$                                               ! String date
       MAP2 MONTH$     ,S,2                            ! Parts of DAT$
       MAP2 D'SL1      ,S,1,           "/"
       MAP2 DAY$       ,S,2
       MAP2 D'SL2      ,S,1,           D'SL1
       MAP2 YEAR$      ,S,2

!       !       !       !       !       !       !       !       !       !

! Get system date:
       BDATE=DATE                                      ! Get system date
       MONTH$=MONTH USING DATE'MASK                    ! Extract month
       DAY$=DAY USING DATE'MASK                        ! Extract day
       YEAR$=YEAR USING DATE'MASK                      ! Extract year

       ?TAB(-1,0);
       ?"MAKEAA - Create A.A files in each PPn of logical disk if not found."
       LOOKUP DIRECT'FILE,TEMP1
       IF TEMP1=0  ?DIRECT'FILE" is missing." : END
       OPEN #1,DIRECT'FILE,INPUT

GET'PPN:
       INPUT LINE #1, INLINE : IF EOF(1)  GOTO END'FILE
       LEFT'BRACK=INSTR(1,INLINE,"[")                  ! Locate PPn
       IF LEFT'BRACK=0   GOTO GET'PPN                  ! None on this line
       RIGHT'BRACK=INSTR(LEFT'BRACK,INLINE,"]")
       IF RIGHT'BRACK=0  GOTO GET'PPN
       TEMP1=INSTR(1,INLINE,":")                       ! Locate device spec
       DEVICE=INLINE[TEMP1-4,TEMP1]

       LOOKUP DEVICE+"A.A"+INLINE[LEFT'BRACK,RIGHT'BRACK],TEMP1
       IF TEMP1#0  GOTO GET'PPN                        ! Skip existing A.A
       ? "Working on account "DEVICE+INLINE[LEFT'BRACK,RIGHT'BRACK]

       OPEN #2, DEVICE+"A.A"+INLINE[LEFT'BRACK,RIGHT'BRACK], OUTPUT
?#2 "; "INLINE[LEFT'BRACK,RIGHT'BRACK]" created "DAT$
?#2 "; Every account should have an A.A file to recover UFDs using MUFDIT."
?#2 "; If MFD is ever damaged, UFD blocks will be identified by A.A files."
       CLOSE #2
       GOTO GET'PPN

END'FILE:
       CLOSE #1
       END