home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1994-11-27 | 3.4 KB | 143 lines |
- >LibHandler
- H Example library file used to control the running of other libraries
- And error handler
- K Note that error handler calls Wimp_CloseDown, and so non-wimp programs
- @ may have to include a dummy version of this routine to keep
- bascompress happy
- USAGE:
- B This should be the first library file to be loaded, and its'
- G hard initialisation called. From then on just use _load_library.
- _LibHandler_version : = 013
- _hard_initialise_LibHandler(max_libs%, need_version%)
- _LibHandler_version<need_version%
- #
- 0, "LibHandler too old"
- max_libs%<1
- 7
- 0, "LibHandler: bad max librarys parameter"
- % max_library_files% = max_libs%
- library_names$(max_library_files%-1)
- library_versions%(max_library_files%-1)
- num_library_files% = 0
- = :
- This is used so can indent nested error handlers.
- " Num_Lib_Error_Levels% = 40
- ! Lib_Error_Level% = 0
- E On_Lib_Error_MODE% = 12 :
- A 16-colour screen.
- ! On_Lib_Error_Continue% =
- !-
- Lib_Errors$(Num_Lib_Error_Levels%-1)
- Wimp_Active% =
- Debug_Wimp% =
- *********************************************************************
- * Load a library file, check it's a new enough version and then, if
- * it hasn't already been loaded, call its' hard initialisation.
- * This procedure could well be recursive.
- * IN: library$ == file name of library.
- * version% == earliest possible version required.
- * OUT: ERROR 0 if bad versions / too many library files.
- _load_library(library$, version%)
- load%, i%, leaf$, e$
- i% = 0
- load% =
- 2. leaf$ =
- library$, 1 +
- library$, "."))
- 3'
- i%<num_library_files%
- load%
- 4- load% = (leaf$<>library_names$(i%))
-
- load%
- i% += 1
-
- load%
- :#
- i%=max_library_files%
- ;9
- 0,"LibHandler: Too many librarys to load!"
-
- =$ library_names$(i%) = leaf$
-
- library$
- ?7 e$ = "'" + library$ + "' does not have a FN_"
- @? library_versions%(i%) =
- ("FN_" + leaf$ + "_version")
- A& num_library_files% += 1
- B%
- This could be recursive.
- C.
- ("FN_hard_initialise_" + leaf$)
- DI
- 1, "Library file '" + library$ + "'s hard init'ion failed"
-
- G)
- version%>library_versions%(i%)
- H8
- 1, "Library file '" + library$ + "' too old"
- _handle_library_error
- iii%, eee$
- Wimp_Active%
- Debug_Wimp%
- P/
- _Wimp_Error(
- $+ " ["+
- )+ "].")
-
- _Wimp_CloseDown
-
- S
-
- _Wimp_Error(
- U!
- =Wimp_Error_Fatal%
-
- _Wimp_CloseDown
-
-
- Y
- [!
- On_Lib_Error_MODE%=-2
- \
- Lib_Error_Level%>0
- ]!
- , Lib_Errors$(0)
-
-
-
-
- b
- c!
- On_Lib_Error_MODE%>=0
- d3
- On_Lib_Error_MODE% :
- Reset screen.
- e
- f#
- "An error has occured..."
- g
- Lib_Error_Level%
- i(
- iii%= 0
- Lib_Error_Level%-1
- j)
- ((7 - (iii% << 1))
- 6) + 1
- k
- Lib_Errors$(iii%);
- l)
- iii%<(Lib_Error_Level%-1)
-
- " in ";
-
-
- iii%
- p
- q$
- $; " (line ";
- ); ")"
- r
- s
- u
-