next up previous contents index
Next: The plrc program Up: Using program resources Previous: Using program resources   Contents   Index

Predicates Definitions

resource3+Name, +Class, +FileSpec This predicate is defined as a dynamic predicate in the module user. Clauses for it may be defined in any module, including the user module. Name is the name of the resource (an atom). A resource name may contain all characters, except for $ and :, which are reserved for internal usage by the resource library. Class describes the what kind of object we are dealing with. In the current implementation, it is just an atom. FileSpec is a file specification that may exploit file_search_path2 (see absolute_file_name2).

Normally, resources are defined as unit clauses (facts), but the definition of this predicate can also imply rules. For proper generation of the saved state generation, it must be possible to enumerate the available resources by calling this predicate with all its arguments unbound.

Dynamic rules can be useful to turn all files in a certain directory into resources, without specifying a resources for each file. For example, assume the file_search_path2 icons refers to the resource directory containing (XPM) icons. The following definition makes all these images available as resources:


\begin{code}
resource(Name, image, icons(XpmName)) :-
atom(Name), !,
file_name...
...n),
expand_file_name(Pattern, XpmFiles),
member(XpmFile, XpmFiles).
\end{code}

open_resource3+Name, ?Class, -Stream Opens the resource specified by Name and Class. If the latter is a variable, it will be unified to the class of the first resource found that has tehe specified Name. If successful, Stream becomes a handle to a binary input stream, providing access to the content of the resource.

The predicate open_resource3 first checks resource3. When succesful it will open the returned resource source-file. Otherwise it will look in the programs resource database. When creating a saved-state, the system normally saves the resource contents into the resource archive, but does not save the resource clauses.

This way, the development environment uses the files (and modifications to the resource3 declarations and/or files containing resource info thus immediately affect the running environment, while the runtime system quickly accesses the system resources.


next up previous contents index
Next: The plrc program Up: Using program resources Previous: Using program resources   Contents   Index
Dr. Richard Botting 2001-12-12