User Tools

Site Tools


Checking if a library is INSTALLed

by Jon Ripley, January 2006

BBC BASIC for Windows provides no built in function to check whether a library has been loaded into memory using the INSTALL command.

The following routine FN_IsInstalled(lib$) implements a method to check if a library is currently INSTALLed:

        DEF FN_IsInstalled(lib$)
        IF ?HIMEM = 0 THEN = FALSE
        LOCAL P%, tmp$
        SYS "CharUpperBuff", !^lib$, LEN lib$
        IF RIGHT$(lib$,4) = ".BBC" THEN lib$ = LEFT$(lib$, LEN lib$ - 4)
        P% = HIMEM
          tmp$ = $$(P%+4)
          IF lib$ = "-" THEN PRINT tmp$
          SYS "CharUpperBuff", !^tmp$, LEN tmp$
          IF lib$ = tmp$ OR tmp$ = lib$ + ".BBC" THEN = TRUE
          P% += ?P%
          WHILE ?P% AND ?P% < &FF
            P% += ?P%
        UNTIL (!P% AND &FFFFFF) = &FFFF00
        = FALSE 

To check if a library is installed use code similar to the following:

        IF FN_IsInstalled(@lib$+"WINLIB") THEN
          PRINT "WINLIB is installed."
          PRINT "WINLIB is not installed."

To list all installed libraries call FN_IsInstalled(“-”).

Installing a library only once

When you INSTALL a library, BBC BASIC for Windows checks whether that library is already installed (version 5.91a or later only), however it performs a case-sensitive comparison of the supplied path/filename. It will reliably detect the same INSTALL statement being executed a second time, but not necessarily a different INSTALL statement which installs the same library but specifies it differently.

Installing a library more than once is safe but wastes memory. If this is a concern, the following routine can be used instead of INSTALL:

        DEF PROC_InstallOnce(lib$)
        IF NOT FN_IsInstalled(lib$) THEN INSTALL lib$
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
checking_20if_20a_20library_20is_20installed.txt · Last modified: 2018/04/15 18:11 by tbest3112