The Fabl Manual
Function Index
Class Index
Globals Index
Libraries
Contents

Title Page
Introduction
Sample Code
Architecture
Syntax
Strong Typing
Polymorphism
Operators
Help
Errors
Configuration
RDF
Namespaces
Owl
Datatypes
Resources
Dot ops
Coercion
Type Casting
nil

Types
string
id
int
double
boolean
Literal
Containers
Functions
void

Home
Regarding
The Path
Classes
Delegation
Functional Values
Read/Write
Load/Store
Libraries
Imports
CGI
Configuration

If Fabl is started in interactive mode without a command shell argument, then it reads the file config.txt in the directory <fablRoot>/bin at startup. In cgi mode it reads cgi.txt. Here are the contents of config.txt:
regularHeapSize = 1000; // in kilobytes
tenuredHeapSize = 5000; // in kilobytes
maxSerializeObjects = 50000;
serializeBufferSize = 1000; // in kilobytes
initFile = "init.fbl"; 

These values of the four allocation parameters will work well for most applications. The first two parameters determine the sizes of the memory areas allocated to the Fabl triple store. (The tenured heap is the main store, while the regular heap is devoted to transient data.) Additional segments of tenured heap are allocated as needed, but if it is known in advance that a large amount of memory will be needed, the tenuredHeap parameter may be set to a larger value. The serializer allocation parameters affect loading and storing of RDF content in the fb format (see the Load/Store section. In Fabl version 2.0.11, the serializer buffers are fixed at the specified initial sizes, and should be set in config.txt to values that are adequate for the application.

The initFile parameter specifies a Fabl file to load after initialization. Many of the globals and functions described in the rest of this section are typically set or called in the initFile.

The values specified in the configuration file must be literals, not expressions. This is because, although the format of the configuration file matches Fabl syntax, it is read before the Fabl interpreter is initialized.

An alternative configuration file may be supplied as a command shell argument. For example, if altconfig.txt has alternate values of the configuration parameters,

fabl altconfig.txt

when typed to a command shell will load altconfig.txt instead of config.txt or cgi.txt.

The function

void quit()

exits the Fabl session. The function

void silent(boolean v)

can be used to prevent any text from being sent to standard output. silent(true) enters silent mode, and silent(false) resumes output. An error terminates silent mode. The function

boolean silent()

returns true if Fabl is currently in silent mode.

The global variable proxyServer should be set in situations where the Fabl installation is running behind a firewall and using a proxy server for access to the internet. The port should be included in the value assigned, eg

proxyServer="http://myproxyserver.com:81";

proxyServer should be nul if a proxy server is not in use; nul is the default value.

The global variable printResult determines whether values of expressions are written to standard output, but does not affect the behavior of write or writeln. Example:

2+3;
-->5
printResult = false;
-->
2+3;
writeln(2+3);
-->5

printResult defaults to true, except in cgi mode.

The global variable echoMode controls whether, when loading a file containing Fabl source code, the input is echoed in a manner analogous to Fabl shell behavior. echoMode also controls the echoing behavior of the Fabl web services for code interpretation, http://fabl.net/eval/expression.html and http://fabl.net/eval/file.html.

The Fabl garbage collector - which automatically reclaims unused storage - can be enabled and disabled using the function:

void garbageCollection(boolean enable)

Garbage collection is enabled by default.

Placing limits on resource consumption and file access

When running in cgi mode on a server to which there is broad, perhaps internet-wide, access, it is necessary to restrict the quantity of computational resources that each Fabl invocation can consume, and also to prohibit unsafe access to the file system. The following functions enact such limitations:

void maxMemory(int mx)

sets the maximum amount of memory that Fabl will allocate for its heap, in kilobytes. The heap is the working memory in which Fabl stores triples, and does not include the memory allocated to the executable. When the limitation is exceeded, an error message is written to standard output, and Fabl exits. maxMemory, if executed more than once, is permitted only to reduce, not increase, the current allocation - otherwise cgi scripts could just hand themselves additional resources, defeating the purpose.

int memoryAllocated()

returns the current memory allocation for the heap in kilobytes. The allocation can only be reduced, not increased, by subsequent calls.

void maxPmSteps(int mx)

sets the maximum number of instructions that Fabl's virtual machine will execute. The current virtual machine runs at the rather stately rate of 7 million instructions per second on a 2 ghz Pentium processor. Like maxMemory, maxPmSteps cannot be used increase a previously set limit.

int pmSteps()

returns the number of instructions executed by the virtual machine so far.

void safeMode(boolean sf)

when passed the input true, puts Fabl into a mode where file access is prohibited. Entry into safe mode cannot be reversed.