home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / ZCPR33 / S-Z / VTCAP11.LBR / DELETE.1Z0 / DELETE.18°
Text File  |  2000-06-30  |  7KB  |  221 lines

  1. ; DELETE
  2. ;
  3. ; This subroutine is responsible for the deletion of a record
  4. ; from the database. Actually, the record will only be marked
  5. ; for deletion. It is the responsibility of the EXIT routines
  6. ; to perform the actual deletion.
  7. ;
  8. ; The method used to mark the files is to set a byte, with an 
  9. ; '*', in the index file. The list subroutine will check this 
  10. ; byte and if the record is deleted, the terminals listing is
  11. ; displayed in the standout mode.
  12. ;  
  13. ; The delete function is a toggle. This means that depressing
  14. ; the [D]elete key will delete and un-delete the record.
  15.  
  16. delete:    push    hl        ; save registers
  17.     push    de
  18.     push    bc
  19.  
  20.     ld    de,fcb3        ; open MERGE.TCP
  21.     call    initfcb
  22.     call    f$mopen
  23.     jp    nz,f?mopen
  24.  
  25.     ld    hl,buf1        ; get start address of buffer to scan
  26.     ld    de,iname    ; get string to scan for
  27.     call    instr        ; find index name in buffer
  28.     jp    nz,delerr    ; error handler
  29.     ld    bc,17        ; point to deletion flag
  30.     add    hl,bc
  31.     ld    a,(hl)
  32.     cp    '*'        ; is record marked for deletion
  33.     jp    z,undel        ; yes - then undelete
  34.     ld    a,'*'
  35.     ld    (hl),a
  36.     ld    a,(delflg)    ; get deletion counter
  37.     inc    a        ; adjust counter to show 1 more deletion
  38.     ld    (delflg),a    ; save counter
  39.     jp    dexit
  40.  
  41. undel:    ld    a,' '        ; undelete mark is a space
  42.     ld    (hl),a        ; save in buffer
  43.     ld    a,(delflg)    ; get deletetion counter
  44.     dec    a        ; adjust counter to show 1 less deletion
  45.     ld    (delflg),a    ; save counter
  46.  
  47. dexit:    ld    hl,tbuf        ; point to TBUF
  48.     call    setdma        ; set DMA
  49.     ld    de,fcb1        ; get record number
  50.     ld    hl,(rec)    ; point to FCB1
  51.     ld    bc,(recof)    ; get offset into database
  52.     add    hl,bc        ; add offset to record number
  53.     call    r$read        ; read record
  54.     jp    nz,r?read    ; error routines
  55.     call    data        ; display data
  56.     pop    bc        ; restore registers
  57.     pop    de
  58.     pop    hl
  59.     jp    exopt
  60.  
  61. delerr:    call    gxymsg
  62.     db    24,5
  63.     db    2,'ERROR',1
  64.     db    ' - Unable to delete record'
  65.     db    0
  66.     call    wait1s
  67.     call    wait1s
  68.     call    at
  69.     db    24,5
  70.     call    ereol
  71.     jp    dexit
  72.  
  73. ; This next routine is responsible for the actual deletion of the marked
  74. ; records in the database. It will use the information in BUF1 which is
  75. ; the NEWFILE database index. The records that are marked for deletion 
  76. ; are so marked in this index. The index records will be read from BUF1
  77. ; and if they are not marked for deletion, they will be copied to a file
  78. ; designated as the output file for the delete function.
  79.  
  80. delex:    ld    hl,buf3        ; point to beginning of BUF3
  81.     ld    a,0        ; put 0 in A
  82.     ld    bc,buf3+2048    ; point to end of BUF3
  83.  
  84. zmore:    ld    (hl),a        ; zero BUF3    
  85.     inc    hl        ; advance pointer
  86.     push    hl        ; save on stack
  87.     sbc    hl,bc        ; have we reached the end
  88.     pop    hl        ; restore from stack
  89.     jp    nz,zmore    ; loop until done
  90.  
  91.     ld    hl,versn    ; point to loaded version number
  92.     ld    de,verbuf    ; point to buffer
  93.     ld    bc,4        ; number of bytes in version number
  94.     ldir            ; save version number in buffer
  95.     
  96. dfile:    ld    hl,buf1        ; point to buffer
  97.     ld    de,buf3        ; point to destination buffer
  98.     
  99. dx:    ld    a,(hl)        ; get first character in terminal name
  100.     cp    ' '        ; is it blank
  101.     jp    z,delwt        ; if blank, we're through
  102.     ld    bc,17        ; get offset to delete flag
  103.     add    hl,bc        ; add offset to buffer pointer
  104.     ld     a,(hl)        ; put character in A
  105.     cp    '*'        ; has record been deleted?
  106.     jp    nz,deltr    ; if not deleted write to BUF3
  107.  
  108. decon:    ld    a,(delflg)    ; get deletion flag
  109.     dec    a        ; decrement counter
  110.     ld    (delflg),a    ; save new counter
  111.  
  112.     inc    hl        ; point to next name
  113.     jp    dx        ; loop until done
  114.  
  115. deltr:    ld    bc,16        ; negative offset to terminal name
  116.     sbc    hl,bc        ; point to terminal name
  117.     ld    bc,16        ; number of bytes to transfer
  118.     ldir            ; move terminal name to BUF3
  119.     inc    hl        ; point to record number
  120.     inc    hl        ; point to next name
  121.     jp    dx        ; loop until done
  122.  
  123. delwt:    call    getv        ; get new version number
  124.     call    gxymsg
  125.     db    23,5
  126.     db    2,'Writing File:  ',1
  127.     db    0
  128.     call    ereol
  129.  
  130.     ld    a,0ffh        ; get set indicator
  131.     ld    (dlfg),a    ; set indicator
  132.     ld    hl,buf3        ; point to BUF3
  133.     jp    wrtndx        ; write to file
  134.  
  135. wrndx:    ld    (buf),hl    ; save buffer address
  136.     ld    de,tbuf        ; point to TBUF
  137.     ld    bc,128        ; number of bytes to move
  138.     ldir            ; move HL to DE
  139.     ld    hl,tbuf        ; point to TBUF
  140.     ld    de,term        ; get string to search for
  141.     ld    b,128        ; length of TBUF
  142.     ld    c,1        ; length of vector to find
  143.     call    scanner        ; find DE in HL
  144.     jp    nz,wrmre    ; if not found, skip inserting version number
  145.     ex    de,hl        ; put destination in DE
  146.     ld    hl,verbuf    ; point to version number buffer
  147.     ld    bc,16        ; length of version number
  148.     ldir            ; move to TBUF
  149.     ex    de,hl        ; restore HL
  150.  
  151. wrmre:    ld     de,fcb3        ; point to FCB
  152.     call    f$write        ; write record to MERGE.TCP
  153.     jp    nz,f?write    ; error routine
  154.     ld    hl,(buf)    ; get buffer address
  155.     ld    bc,128        ; length of buffer
  156.     add    hl,bc        ; increment buffer pointer
  157.     ld    (buf),hl    ; save new buffer address
  158.     dec    hl        ; point to last byte of buffer
  159.     ld    a,(hl)        ; place character in A
  160.     cp    0        ; is it zero
  161.     inc    hl        ; point to first byte again
  162.     jp    nz,wrndx    ; if zero, end of transfer
  163.  
  164. ; Read entries in BUF3 and find the corresponding data blocks and
  165. ; write them to the NEW TCAP file. Deleted records will be processed
  166. ; from this point. If the deleted flag is set, the exit routines will
  167. ; jump to this point for processing.
  168.     
  169. wrnd:    ld    hl,buf3        ; point to BUF3
  170.     ld    (buf),hl    ; save buffer address
  171.  
  172. wnxt:    ld    hl,(buf)    ; point to buffer
  173.     ld    a,(hl)        ; get first character in buffer
  174.     cp    0        ; if blank, we're through
  175.     jp    z,mexit        ; exit routine
  176.     ld    de,termid    ; point to terminal id string
  177.     ld    bc,16        ; length of id string
  178.     ldir            ; transfer id string to TERMID
  179.     ld    hl,buf1        ; point to string to scan
  180.     ld    de,termid    ; point to string to scan for
  181.     call    instr        ; scan BUF1 for TERMID
  182.     jp    z,wtp        ; if found - write from NEW TCAP
  183.     ld    hl,buf2        ; point to vector to scan
  184.     call    instr        ; scan BUF2 for TERMID
  185.     jp    nz,merr        ; merge error handler
  186.     ld    de,fcb2        ; point to CURRENT TCAP file
  187.     ld    bc,(recof2)    ; get proper record offset
  188.     ld    (ofset),bc    ; save in buffer
  189.     jp    wtp1        ; read/write record
  190.  
  191. wtp:    ld    de,fcb1        ; point to NEW TCAP file
  192.     ld    bc,(recof)    ; get proper record offset
  193.     ld    (ofset),bc    ; save in buffer
  194.  
  195. wtp1:    ld    bc,17        ; offset to delete flag
  196.     add    hl,bc        ; point to delete flag
  197.     ld    a,(hl)        ; put delete flag in A
  198.     cp    '*'        ; is record deleted?
  199.     jp    z,wdl        ; if yes - go to next record
  200.     dec    hl        ; point to record number
  201.     ld    a,(hl)        ; place in A
  202.     cp    0ffh
  203.     jp    nz,wtcn
  204.     ld    a,0
  205.  
  206. wtcn:    ld    (rec),a        ; save record number
  207.     ld    hl,(rec)    ; put record number in HL
  208.     ld    bc,(ofset)    ; get record offset
  209.     add    hl,bc        ; add in record offset
  210.     call    r$read        ; read file
  211.     jp    nz,r?read    ; error routines
  212.     ld    de,fcb3        ; point to MERGE.TCP FCB
  213.     call    f$write        ; write to file
  214.     jp    nz,f?write    ; error routines
  215.  
  216. wdl:    ld    hl,(buf)    ; get buffer address
  217.     ld    bc,16        ; length of entry in BUF3
  218.     add    hl,bc        ; advance to next entry
  219.     ld    (buf),hl    ; save new buffer address
  220.     jp    wnxt        ; contiue
  221.