| |
|
| Format |
OPEN
(chan[,option])"*MEMORY*
[ ; keydef ]
" Where:
| chan |
Channel
or logical file number. |
| options |
BSZ=num
File option for specifying record size
(number of bytes). The default record size is
1,024 bytes unless it is overridden via BSZ=. |
| keydef |
The keydef
field, if supplied, can be used to define
alternate logical keys for the data in the *MEMORY*
file. See Alternate Keys below. |
| *MEMORY* |
Keyword,
not case-sensitive. Logical filename, enclosed in
quotation marks within OPEN
directive. (Include asterisks in syntax.) |
|
| |
|
| Description |
ProvideX
supports a memory-resident logical file called *MEMORY*;
i.e., this file is basically a memory-resident queue of
records. Create the memory-queue file and assign the
given logical file number (channel) via the OPEN
directive. |
|
|
| *Note* |
As of
Version 5.10, the maximum key size for Memory files
(without a keydef see below) has been increased from 255 to 8192
characters. |
|
|
| |
ProvideX
recognizes *MEMORY* at run time and
deals with it internally. Once *MEMORY* is open, you can
gain I/O access to memory-resident records in the same
manner as you can to Direct files by record index
or by key, using the following I/O directives:
READ Read Data from
File
and READ RECORD Read Record
from File,
WRITE Add/Update Data
in File and WRITE RECORD Write Record,
CLOSE Close File,
MERGE Read/Append Lines from
File,
REMOVE Delete Record from File.
The first WRITE determines
the file access method; i.e., the IND=
option specifies Indexed file handling, and KEY= specifies
Direct file handling (externally-keyed files).
The functions IND(
), KEF( ), KEL( ),
KEN( ), KEP( ), KEY(
), and RNO( )can be used with
memory-queue files.
|
|
|
| *Note* |
Adding
records to a memory file by IND( ),
pushes all the records at that index down one, and
inserts a new record. To modify a record in an index
file, remove the old record and then insert the new one. |
|
|
| |
To Delete a Memory File Use CLOSE (chan)
to delete a Memory file and return memory to the
system.
|
| |
|
| Alternate
Keys |
Memory files
can have alternate keys specified. When opening a memory
file you can add a KEYDEF= option that defines the
alternate key definition. Standard ProvideX alternate key
definitions can be used as follows:
| Code |
Description |
| "A" |
Ascending key (assumed). |
| "B[.n]" |
Indicates that the segment contains
a numeric value. Field will internally be
converted to is binary equivalent and stored into
the data file. Negative numbers will ocurr before
position numbers in ordinary numeric value
sequence. If
'.n' is provided, the value is 'n' is assumed to
be the number of digits to the right of the
decimal point that are to be maintained. Before
the internal value is created the value will be
TRUNCATED to the number of decimal places
specified. See Numeric Key
Segments in the section on KEYED files.
Numeric keys are a +PxPlus
Exclusive
|
| "D" |
Descending order (default is
ascending). |
| "U"
|
If you declare an alternate key
segment as unique, then no duplicate keys are
allowed on writing a record. System will generate
an Error #11: Record not found or Duplicate key
on write if the key being added already exists on
the file. If any segment in a key definition is
marked as unique, then the entire key is
considered unique. |
| "C" |
Force uppercase for individual key
segments to create upper-case insensitive keys |
| "L" |
Force lowercase for individual key
segments to create lower-case insensitive keys. |
| "T" |
Force automatic accent translation
for individual key segments (i.e., to translate
accented/extended characters to their
non-accented counterparts) useful when sorting
multilingual characters into a single unified
sort sequence. |
| "K[:n]" |
Null key suppression. n is the hex
value of the character to suppress if all
characters match (defaults to $00$ if not
specified). If the entire key evaluates to null,
the key will not be a part of this key tree. This
cannot be used on a primary key. Unlike standard
keyed files this can be used in conjunction with
the "N" option. |
| "N[:n]" |
Null segment suppression. n is the
hex value of the character to suppress if all
characters match. If any segment within the key
evaluates to null, the key will not be a part of
this key tree. Unlike standard keyed files this
can be used in conjunction with the "N"
option. |
For Example to create and
open a memory file with a 6 byte external key, an eight
byte UNIQUE key on field 2, and a 30 byte key on field
three you could use:
OPEN (1)
"*memory*;KEYDEF=6,[2:1:8:""U""],[3:1:30]"
Keynames can also be
specified, if desired.
|
|
|
| *Note* |
Unlike
standard *MEMORY* files,
*MEMORY* files created using the keydef
option cannot have record inserted by record index. The
key fields are always used. |
|
|
| *Note* |
Also Unlike
standard keyed files, the number of keys, the number of
key segments, and the field length for keys in *MEMORY*
has no preset limit and is only bound the by amount of
memory available in the system.
The removal of the
standard keyed file limits on *MEMORY*
files is an +PxPlus
Exclusive
|
|
|
| |
|
| See
Also |
DIRECT Directive
KEYED Directive |
| |
|
| Example |
The
following example illustrates how to open and use the
Memory file:
00010 mmf=hfn
00020 open
(mmf)"*memory*"
00030 print
'CS'
00040 input
"Name (Press F4 to end):",name$
00050 if
ctl=4 then goto 0100
00060 input
"Address:",addr$
00070 input
"Position:",pos$
00080 write
(mmf,key=name$)iol=mmfLst
00090 goto
0030
00100 print
'CS'
00110 select
iol=mmfLst from mmf begin "" end
"z"
00120 print
"Name:",name$
00130 print
"Address:",addr$
00140 print
"Position:",pos$
00150 print
"----------"
00160 next
record
00170 end
00180
mmfLst: iolist name$,addr$,pos$
|