FileIO Functions

 

Overview

The Analytic Information Server engine supports a number of data file and console i/o functions. Data files are managed similarly across all host operating systems, so Lambdas need not concern themselves with differences in local operating systems.

Data files are viewed as named, byte address spaces up to 2 gigabytes per file. Each individual byte in a data file is addressable, and may be read or written. Writing to a data file automatically increases its size. Analytic Information Server supports the storage and retrieval of object closures, within data files, at any byte location. Managing the structure within a data file is entirely the responsibility of the assigned Lambda.

Object Closure

Analytic Information Server supports the storage and retrieval of object closures, within data files, at any byte location. An object closure record contains the original object saved, together with all the objects it reaches. (See Object Closure record for Smith below). Before an object is saved to a data file, it is transformed into an object closure byte stream.

FileIO Variables

The sections which follow, describe all of the global variables which operate upon or are specifically related to the data file and console i/o.

_path

The global variable, _path, is reserved by the system to hold the directory and path name of the current working directory. The _path variable is set to the empty string "" at system startup. It is the programmers responsibility to initialize the _path variable. When the _path variable is referenced, the text contents of the _path variable are automatically attached to the beginning of database archive file named in the new function. The contents of the _path variable are also automatically prepended to the file names in both the new ObjectRepository: function and the fileOpen function.

Type: Variable

When To Use

The _path is a global variable used to hold a path name string assigned by the programmer. If the _path variable is something other than a null string, the _path variable string will be prepended to the filename specified in the new function.

 

Example1

(setq _path "C:\\Abase\\";)
		(display _path) ; Returns "C:\\Abase\\"
		(new ObjectRepository:"myarchive.odb"))
		The database archive file name is now "C:\Abase\myarchive.odb"

Example2

(setq _path "d:\\test\\")
		(new ObjectRepository: "myarchive.odb"))
		The database archive file name is now
		"d:\test\myarchive.odb"

_saveTypes

The _saveTypes is a global variable that contains a Boolean value. The contents of the _saveTypes variable determines the calculation of the object closure when objects are saved to an Object Repository, a file, or a vector. At system startup, the _saveTypes variable is initialized to False. If the _saveTypes variable is later set to True, global value and type information are to be saved along with symbol objects.

Type: Variable

When To Use

Analytic Information Server Symbols have the two properties associated with them: the type property and global value property. Typically, the preservation of type and global value information is needed when a Symbol is being used as a container. However, Symbols, are themselves data and may not be associated with a type or value. In the latter case, the type and global value properties are not important. The _saveTypes variable allows the programmer to control whether type and global information should be saved along with a Symbol object when the object is saved in an Object Repository, or file or vector.

Example1

(defineStructure x: Old1:) ;; Global type info linked to x
		(1 2 3)) ;; Global value stored in x
		(setq y x:) ;; y contains the Symbol x:
		(new ObjectRepository: "test.db"))
		(setq _saveTypes false) ;; Do NOT save Symbol global and type info
		(setq db[0] y) ;; Save record data only
		(setq x #void) ;; Destroy global value in x
		(defineStructure x: New1: ) ;; Destroy global type info in x
		(setq y db[0]) ;; Read previously saved record into y<
		(writeln "y=" y ", x=" x ", fieldsof
		(x)=" (fieldsOf x: ) )
		The result output from the writeln statement is:
		(x)=#{New1: #void}
		Note that the contents of the Symbol x: is #void.
		Note that the type information of the Symbol x: is different from the
		original defineStructure statement.

Example2

(defineStructure x: Old1:) ;; Global type info linked to x
		(1 2 3)) ;; Global value stored in x
		(setq y x:) ;; y contains the Symbol x:
		(new ObjectRepository: "test.db"))
		(setq _saveTypes true) ;; DO save Symbol global and type info
		(setq db[0] y) ;; Save Symbol global and type info
		(setq x #void) ;; Destroy global value in x
		(defineStructure x: New1: ) ;; Destroy global type info in x
		(setq y db[0]) ;; Read previously saved record into y
		(writeln "y=" y ", x=" x ", fieldsOf
		(x)=" (fieldsOf x: ) )
		The result output from the writeln statement is:
		(x)=#{Old1: #void}
		Note that the contents of the Symbol x: is the Vector #(1 2
		3)
		Note that the type information of the Symbol x: is the same as the
		original defineStructure statement.

nil

The nil variable returns the value #void.
Type: Variable

When To Use

The nil variable can be used whenever it is necessary to clear a variable.

Example1

(setq x 45) 
		(display x) ; Returns 45 
		(setq x nil) 
		(display x) ; Returns #void

FileIO Functions

Here is a list of the links to the AIS built-in Math Functions with their corresponding examples.

closeLogcompressdecodedisplaydisplay
encodefdisplayfdisplayfileClosefileClose
fileDisplayfileDisplayfileErasefileErasefileOpen
fileOpenfileReadfileReadfileReadRecordfileReadRecord
fileReadRecordfileResizefileResizefileResizefileSeek
fileSeekfileSeekfileWritefileWritefileWrite
filewritelnfilewritelnfilewritelngetHttpgetHttp
loadLibloadObjectopenLogopenLogpostHttp
postHttpreadHtmlPagereadHtmlPagerequestHttprequestHttp
runrunsaveObjectsaveObjectsystem
systemuncompresswritelnwritelnwriteln