;*************************************************************** ; CLRBRK - Clear a random file to ]'s. ; ; Dave Heyliger's CLRAND modified by S.Chirico. ; It ini's with ] instead of 0. Caution, don't have to be in opr: ; acct, and prgm does not ask for confirmation (tho you can just ; uncomment the proper lines, to take those dangerous things out). ; ; will work from ANY acct, so caution ! ; Does NOT ask for confirmation ! ; ; Usage: CLRBRK {filespec} ; ; Purpose: after you use CREATE , this will fill the entire file ; with ] ;*********************************************************************** SEARCH SYS SEARCH SYSSYM SEARCH TRM ; PHDR -1,0,PH$REE!PH$REU!PH$OPR ;must be in OPR: .OFINI .OFDEF IDDB,D.DDB ;DDB for the file .OFSIZ IMPSIZ ;get the inpure space GETIMP IMPSIZ,A3 ;A3 points to varibles ;process input line BYP ;bypass bs LIN ;just a CR? BNE 10$ ;nope TYPECR TYPECR < (default extension is .DAT)> EXIT ;set up DDB and use input as filename to see if valid 10$: LEA A1,IDDB(A3) ;point to a DDB MOVB #D$ERC!D$BYP,IDDB+D.FLG(A3) ;set D$ERC bit (trap errors) FSPEC @A1,DAT ;get the filename CMPB IDDB+D.ERR(A3),#D$ESPC ;error? BEQ INERR ;yup CMP IDDB+D.FIL(A3),#0 ;just a ".xxx"? BNE INOK ;nope, ok so far INERR: TYPECR EXIT ;looks good, see if random file INOK: LEA A1,IDDB(A3) ;point to DDB INIT @A1 ;initialize LOOKUP @A1 ;find the file BNE NOFILE ;nope - error CMPW IDDB+D.WRK+6(A3),#-1 ;random file? JEQ AOK ;yup, continue LEA A2,IDDB+D.FIL(A3) ;nope, point to file TYPE PFILE @A1 ;type out file TYPECR < is not a random file.> ;and error message EXIT ;then quit NOFILE: TYPECR EXIT ;double check the users intentions AOK: ; CRLF ; TYPE ; KBD ; CTRLC END ;quit on ^C ; CMPB @A2,#'Y ;yes? ; JNE END ;nope ;now get the number of blocks and clear each one MOV IDDB+D.WRK(A3),D2 ;D2 holds the number of blocks OPENR @A1 ;open the file READIT: READ @A1 ;get a block LOOP: MOV #128.,D3 ;number of longword clears MOV IDDB+D.BUF(A3),A4 ;A4 points to block 10$: MOVB #'],(A4)+ MOVB #'],(A4)+ MOVB #'],(A4)+ MOVB #'],(A4)+ ; CLR (A4)+ ;zero it out DEC D3 ;one less to do BNE 10$ ;still more to do WRITE @A1 ;write the block DEC D2 ;one less block to do BEQ END ;if zero, we are done INCW IDDB+D.REC+2(A3) ;point to next block BR READIT ;and read it END: EXIT END .