This content is archived and may be deprecated or obsolete and is presented in the hope that it may still be useful.
REM InstallMk2 Version 1.00 15-May-2005 REM (C) Jon Ripley, 2005 REM This code may be used and modified freely : REM PROC_Install(lib$) REM Purpose: REM Load a library if it is present on the local machine REM No error given if operation fails DEF PROC_Install(lib$):LOCAL f%:f%=FALSE REM FN_Install(lib$) REM Purpose: Load a library if it is present on the local machine REM Returns: REM TRUE - Library exists and has been INSTALLed REM FALSE - Library cannot be found DEF FN_Install(lib$):LOCAL f%:f%=TRUE LOCAL libf%,tmp$ tmp$=lib$:ok%=FN_FileExists(tmp$) IF NOT ok% tmp$=FN_ReadBB4WInstallPath+"LIB\"+lib$:ok%=FN_FileExists(tmp$) IF NOT ok% tmp$="LIB\"+lib$:ok%=FN_FileExists(tmp$) IF NOT ok% tmp$="..\LIB\"+lib$:ok%=FN_FileExists(tmp$) IF ok% THEN INSTALL tmp$ IF f% THEN =ok% ELSE ENDPROC : REM FN_FileExists(file$) REM Purpose: Test the existence of a file REM Returns: REM TRUE - if the the file pointed to by f$ exists REM FALSE - if the file does not exist DEF FN_FileExists(file$) LOCAL h%,ok% h%=OPENINfile$:ok%=h%:IF ok% CLOSE#h% =(ok%<>0) : REM FN_BB4WIsInstalled REM Purpose: Determine if BBC BASIC for Windows is installed REM Returns: REM TRUE - BBC BASIC for Windows is installed REM FALSE - BBC BASIC for Windows is not installed DEF FN_BB4WIsInstalled LOCAL ok%,tmp$ tmp$=FN_ReadBB4WInstallPath IF tmp$<>"" THEN ok%=FN_FileExists(tmp$+"bbcwin.exe") =ok% : REM FN_ReadBB4WInstallPath REM Purpose: Read the BBC BASIC for Windows installation path REM Returns: REM The path to the BBC BASIC for Windows installation directory or, REM a NULL string if BBC BASIC for Windows is not installed DEF FN_ReadBB4WInstallPath LOCAL hkey%,res%,lbuf%,type% lbuf%=255:DIM buf% LOCAL lbuf%:?buf%=13 SYS "RegOpenKeyEx", &80000002, "Software\Microsoft\Windows\Help", 0, &20001, ^hkey% TO res% IF res%=0 THEN SYS "RegQueryValueEx", hkey%, "bbcwin.hlp", 0, ^type%, buf%, ^lbuf% TO res% IF res%=0 THEN buf%?(lbuf%-1) = 13 SYS "RegCloseKey", hkey% ENDIF =$buf%