Text

 

Text Overview

Analytic Information Server supports the Text Native data type. The Text data type is an immediate string of from zero to nine 8 bit ASCII data items followed by a null (0) value. (Note: inside a Word only, Text values are stored in the 80 bit immediate area of the Word).

The Analytic Information Server Lisp compiler, Lisp, optimizes Strings for maximum performance. String constants containing less than 15 characters are assigned as a Text data type. All Text data can be used as arguments to any of the String functions (append, downcase left, mid, upcase, etc.) The most critical difference between String and Text is that a String is an object that is stored on the heap and is managed by the Heap manager and Text is immediate data that is copied on the stack , and behaves just like numbers, dates, time, etc.

Handling of Immediate Text versus Heap or Object Data

Most of the time, the transition from Text to String or String to Text is transparent, however, the user must be aware of the radical difference between the handling of immediate data and Heap data. There are special "gotchas" that occur because of the differences in handling of Text and String types.

There is a notion of destructive and non-destructive functions. A certain class of functions performs an operation on the data itself and another group of functions performs the operation on the data, which is loaded on the stack. The append function is an example of a non-destructive function:

(setq greetings "HELLO")

 

(setq greetings (new String: "HELLO") )

 

(type greetings)

Text

(type greetings)

String

(append greetings " WORLD")

 

(append greetings " WORLD")

 

(writeln greetings)

"HELLO"

 

"HELLO"

 

The downcase function is an example of a destructive function:

(setq greetings "HELLO")

 

(setq greetings (new String: "HELLO") )

 

(type greetings)

Text

(type greetings)

String

(downcase greetings)

 

(downcase greetings)

 

(writeln greetings)

"HELLO"

 

"hello"

Note that for a String object, the downcase function converts the contents to lowercase and replaces the old contents with the lowercase version. The Text data type is not "destroyed" because a reference to a Text item is just like a reference to other immediate native types (Void, Boolean, Number) causes the immediate value to be loaded on the stack and any modification remains on the stack unless explicitly saved. For example:

(setq aNum 1)

(add1 aNum) ;Performs the operation on the Stack

(writeln aNum) ;Prints 1

(setq aNum (add1 aNum)) ;Performs the operation on the Stack

(writeln aNum) ;Prints 2

When to Use

The Text Native data type is used for is hold string constants containing less than 15 characters

Text Constants

Analytic Information Server supports three forms for text constants: Double Quotes, Braces, and Quoted Left Brace.

 

Double Quotes: The double quote character ( " ) is used as a way of indicating text constants. Analytic Information Server string constants are case-sensitive, may include blanks, special characters, but not imbedded double quote characters.

"John Doe"

The backslash character ( \ ) is used as a way of accepting any character as alphabetic within a text constant and in other special situations.

 

"Text \" "

 

Braces: The brace character ( { ) is used as a way of indicating text constants. The text constant ends with a matching closing brace character ( } ). Such Analytic Information Server string constants are case-sensitive, may include blanks, special characters, imbedded double quote characters, may include imbedded brace characters, and terminate with the first matching left brace character.

{John Doe}

 

 

Quoted Left Brace: The quote character ( ' ) followed immediately by the left brace character ( { ) is used as a way of indicating trailing text constants. The text constant ends with the end of the input source. Such Analytic Information Server text constants are do not examine the content of the text constant. The trailing text constant begins with the '{ special character pair, and terminates with the end of the input source.

 

setq _x '{Text here

 

Note: This form is used by Visual Basic or C++ to send long text commands (with arbitrary contents) to Analytic Information Server.

Native Data Type

The Text Data Type is an example of an AIS Native Data Type.

Analytic Information Server stores all of its Native Data Types in Virtual Machine Containers. All containers are stored in memory. Containers provide the basic storage mechanism for modeling data of all types. Containers provide these fundamental characteristics:

Ability to hold any type of data (including code) at any time.

Ability to know what type of data is contained.

Ability to be stored, retrieved and evaluated by the system.

Ability to handle type conversion, and memory management automatically.

Containers come in two sizes, Large and Small. Small containers are six bytes in length, and large containers are ten bytes in length. Large containers can store larger amounts of data immediately and place less of a burden on the Heap manager. Small containers require less immediate space, but place more of a burden on the Heap manager.

Large containers can store the following data types immediately and does not require the services of the Heap manager:

Small containers can store the following data types immediately without placing additional burden on the Heap manager:

Analytic Information Server containers can be saved and loaded to and from persistent (database) storage at any time. Containers with immediate data are saved on disk in fixed length records equal to the size of the container. Containers with Heap object references are saved in fixed length records, which are automatically expanded to include the contents of the Heap object, and any objects referenced by the Heap object, etc. This feature is called Object Closure Management and is automatic with every Analytic Information Server container database save. Analytic Information Server containers may be loaded from any database repository record at any time. If the data in the record is immediate, the database load fills the container with the immediate data. If the data in the record is an object closure, the database load fills the container with a Heap object reference, and all of the objects in the record are loaded back into the Heap with the same referential relationships they had when they were saved.

 

Data Type Functions

The String functions also work with the Text Data Type.

 

Data Type Examples

The String functions also work with the Text Data Type. See the String Data Type examples.