:: RmvLibrary.btm
::
:: This allows the removal of all in-memory functions from a specific library
::
@setlocal
@echo off
:: Assume that library files are located in _startpath\library
set LibPath=%_startpath\library
:: Scratch files location
set utils=c:\utils
:: If a library name was not entered on the command line...
iff %# eq 0 then
Gosub LibsLoaded
quit
endiff
set Lib2Remove=%1
:: Get a list of the libraries
ffind /v/m/t" {" "%LibPath\*.library" > %utils\LibRemove.list
:: No library has been found yet
set FoundLib=N
:: Loop through the list of libraries
do LibLine in @%utils\LibRemove.list
iff %@left[4,%LibLine] eq ---- then
iff %@word["\",-0,%LibLine] eq %Lib2Remove then
:: Found the library
set FoundLib=Y
endiff
iterate
endiff
iff %FoundLib eq Y then
iff %@len[%LibLine] eq 0 then
quit
else
:: Remove the library function
on error gosub CantFind
library /d %@word[0,%LibLine]
on error
endiff
endiff
enddo
endlocal
quit
:: Display libraries
:LibsLoaded
ffind /k/m/v/t"----" %utils\LibRemove.list > clip:
do theLibrary in @clip:
echo %@word["\",-0,%theLibrary]
enddo
Return
:: Cannot find the library function in memory
:CantFind
iff %_? eq 2 then
echo Library function %@word[0,%LibLine] not loaded.
endiff
Return