home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol096 / erq.a86 < prev    next >
Text File  |  1984-04-29  |  2KB  |  139 lines

  1.     title    'ERQ - Selective file erase'
  2.  
  3. CR    EQU    13
  4. LF    EQU    10
  5. ESC    EQU    27
  6. TFCB    EQU    5CH
  7.  
  8.     org    100h
  9.  
  10. erq:    mov    dx,TFCB
  11.     mov    cl,17    ;Search first
  12.     CALL    BDOS
  13.     cmp    al,255
  14.     jnz    FILFND
  15.     mov    dx,offset NFMSG
  16.     call    OUTBUF
  17.     mov    cl,0
  18.     jmp    BDOS
  19. OUTBUF:    mov    cl,9    ;Print string
  20.     jmp    BDOS
  21. FILFND:    mov    bx,offset NAMBUF
  22.     PUSH    bx
  23. NXTFIL:
  24.     mov    cl,5
  25.     shl    al,cl
  26.     add    al,81h
  27.     mov    ah,0
  28.     mov    si,ax
  29.     POP    di
  30.     mov    cx,11
  31.     rep movs al,al
  32.     PUSH    di
  33.     mov    cl,18    ;Search next
  34.     mov    dx,tfcb
  35.     CALL    BDOS
  36.     cmp    al,255
  37.     jnz    NXTFIL
  38.     POP    bx
  39.     mov    byte ptr [bx],80H    ;End of list indicator
  40.     mov    bx,offset NAMBUF
  41. DELCHK:    mov    NBPOS,bx
  42.                 ;Output name
  43.     mov    cx,8
  44. NXTCR2: mov    al,[bx]
  45.     AND    al,7FH
  46.     cmp    al,' '
  47.     jz    ENDNAM    ;End of name
  48.     PUSH    bx
  49.     PUSH    cx
  50.     CALL    CONOUT
  51.     POP    cx
  52.     POP    bx
  53.     INC    bx
  54.     loop    NXTCR2
  55. ENDNAM:    mov    ch,0
  56.     ADD    bx,cx
  57.     PUSH    bx
  58.     mov    al,[bx]
  59.     AND    al,7FH
  60.     cmp    al,' '
  61.     jz    ENDTYP    ;No filetype
  62.     mov    al,'.'
  63.     CALL    CONOUT
  64.                 ;Output type
  65.     mov    cx,3
  66.     POP    bx
  67.     PUSH    bx
  68. NXTCR3: mov    al,[bx]
  69.     AND    al,7FH
  70.     cmp    al,' '
  71.     jz    ENDTYP    ;End of type
  72.     PUSH    bx
  73.     PUSH    cx
  74.     CALL    CONOUT
  75.     POP    cx
  76.     POP    bx
  77.     INC    bx
  78.     loop    NXTCR3
  79. ENDTYP: mov    dx,offset DFMSG1    ;Output rest of the message
  80.     CALL    OUTBUF
  81.     POP    bx
  82.     test    byte ptr [bx],80h
  83.     jz    NOTR_O    ;Check for file R/O
  84.     mov    dx,offset DFMSG2
  85.     CALL    OUTBUF
  86. NOTR_O: mov    dx,offset DFMSG3
  87.     CALL    OUTBUF
  88.     mov    cl,1    ;Console input
  89.     CALL    BDOS
  90.     cmp    al,ESC
  91.     jnz    $+3
  92.     RET
  93.     AND    al,5FH    ;Convert lowercase to uppercase
  94.     cmp    al,'Y'
  95.     jnz    NXTCHK
  96.     mov    si,NBPOS
  97.     mov    di,TFCB+1
  98.     mov    cx,11
  99.     rep movs al,al
  100.     mov    bx,TFCB+9
  101.     test    byte ptr [bx],80h
  102.     jz    NTR_O
  103.     and    byte ptr [bx],7fh
  104.     mov    dx,TFCB
  105.     mov    cl,30    ;Set file attributes
  106.     CALL    BDOS
  107. NTR_O:    mov    dx,TFCB
  108.     mov    cl,19    ;Delete file
  109.     CALL    BDOS
  110. NXTCHK:    mov    al,CR
  111.     CALL    CONOUT
  112.     mov    al,LF
  113.     CALL    CONOUT
  114.     mov    bx,NBPOS
  115.     add    bx,11
  116.     test    byte ptr [bx],80h
  117.     mov    cl,0
  118.     jnz    bdos
  119.     jmp    DELCHK
  120.  
  121. CONOUT: mov    dl,al
  122.     mov    cl,2    ;Console output
  123. BDOS:
  124.     push    es
  125.     int    224
  126.     pop    es
  127.     ret
  128.  
  129. NFMSG    db    'File(s) not found$'
  130. DFMSG1    db    ' exists$'
  131. DFMSG2    db    ' and is R/O$'
  132. DFMSG3    db    '.  Do you want it deleted?$'
  133.  
  134. NBPOS    dw    0
  135. NAMBUF    rs    11*64
  136.     db    0
  137.  
  138.     END
  139.