Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Remove a set of Library functions

Aug
1,929
71
I have several sets of library functions. Example;
Code:
c:\users\jlc\utils>RmvLibrary.btm
datesubs.library
vb.library
vfp.library

I can use the library command to see all of the library functions loaded into memory;
Code:
c:\users\jlc\utils>library
0321
0403
0617
0831
1001
1025
1221
1225
1231
DoCmd
Eval
setevent
SetVar
StartVFPServer
StopVFPServer
Test
vb

I want to remove the functions in the vfp.library from memory;
Code:
c:\users\jlc\utils>RmvLibrary.btm vfp.library

The library command now shows;
Code:
c:\users\jlc\utils>library
0321
0403
0617
0831
1001
1025
1221
1225
1231
setevent
vb

...that the functions from the vfp.library have been removed from memory.

Code:
:: 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

Joe
 
Back
Top