Wednesday, November 15, 2006

Using .factor-boot-rc and .factor-rc

Update: I changed the syntax to work with the new directory layout.

The two resource files Factor tries to run, if they exist, are .factor-boot-rc and .factor-rc, at bootstrap and run-time respectively. You have to create these files yourself and place them in your home directory, e.g. the directory returned by the home word.

If I used Textmate on a Mac, my .factor-boot-rc would look like this:
USING: modules namespaces ;
REQUIRES: libs/textmate ;

Here is the boot file for gvim in Windows XP:
USING: modules namespaces ;
REQUIRES: libs/vim ;
USE: vim
"c:\\program files\\vim\\vim70\\gvim.exe" vim-path set-global


Now for loading libraries. Some of the modules in contrib/ require that you load your library before running. Here are three examples of a .factor-rc that loads libraries.

Loading PostgreSQL on a Mac:
USING: alien ;
"postgresql" "/opt/local/lib/postgresql81/libpq.dylib" "cdecl" add-library

PostgreSQL and SQLite on Windows:
USING: alien ;
"postgresql" "C:\\Program Files\\PostgreSQL\\8.1\\bin\\libpq.dll"
"cdecl" add-library
"sqlite" "C:\\Program Files\\sqlite\\sqlite3.dll"
"cdecl" add-library
SQLite on Linux:
USING: alien ;
"sqlite" "libsqlite3.so" "cdecl" add-library

3 comments:

tomtempest said...

Hi, on the Mac, if you start Factor.app, home points to your user directory e.g. "/Users/tempest" and not where your "f" application is. So where do I put the .factor-rc file. Things like "contrib/space-invaders" run-module loads, but can't find the file invaders.rom, if I put it to where "f" lies.
What is the right way of assuming relative paths?

Cheers tempest

Chris Double said...

I've submitted a patch which should go to the main factor repository soon to fix space invaders problem of not finding the rom. With this patch it will always find the rom if it is placed in the contrib/space-invaders directory.

Unknown said...

A helpful tip, for people (like me) who stumble across this post in 2010: some things in Factor have changed. Put something like this (with the right editors vocab for you) in the config file instead:


USING: namespaces ;
USE: editors.macvim