Guides/Keyed Files

From J Wiki
Jump to: navigation, search
Component Files | Keyed Files

Keyed Files (keyfiles)

A keyed file is a J component file in which the components are accessed using keywords. A keyword may be any character string.

Load the keyed file system with:

   load 'keyfiles'

This defines the main functions:

name description
keycreate create file
keydir keyword directory
keyerase erase file
keyread read data for keyword
keywrite write date for keyword

When reading: if keyword not found, return '' else return value.

When writing: if data='' then the keyword is deleted

For example:

   keycreate 'mydata'
   'Peter Rabbit' keywrite 'mydata';'name'
   'Lake District' keywrite 'mydata';'loc'
   keydir 'mydata'
loc  name
   keyread 'mydata';'loc'
Lake District