Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 36
Transferring Data Between an Extended Data
Segment and a File
For example, the following statements transfer 10 bytes of data from the beginning of
the extended data segment to the terminal:
INT(32) .EXT EXT^PTR := BASE^ADDRESS;
.
.
WCOUNT := 10;
CALL WRITEX(TERM^NUM,EXT^PTR,WCOUNT);
In the above example, BASE^ADDRESS is the byte address of the beginning of the
extended data segment. This value was returned either by the call to
SEGMENT_ALLOCATE_ that allocated this segment or by a call to the
SEGMENT_GETINFO_ or SEGMENT_USE_ procedure.
Transferring Large Buffers Quickly
It is usually safer to handle large buffers in an extended data segment (or in the upper
half of the TNS user data segment) than it would be to buffer such data in the data
stack itself; you avoid running the risk of filling up the data stack with your large buffer.
To help perform data transfers to such buffers efficiently, you can use SETMODE
function 141.
SETMODE function 141 enables and disables transfers of larger blocks of data
between extended data segments and a disk file. Using SETMODE function 141 with
other I/O procedures, you can transfer up to 56K bytes of data between extended data
segments and a DP2 disk file that has been opened for unstructured access. (See
Section 5, Communicating With Disk Files, for a discussion of unstructured file
access.) The amount of data transferred must be a multiple of 2048 bytes.
To enable large transfers, call the SETMODE procedure as follows:
LITERAL LARGE^TRANSFERS = 141,
ENABLE = 1,
DISABLE = 0;
.
.
CALL SETMODE(FILE^NUMBER,
LARGE^TRANSFERS,
ENABLE);
After the call to SETMODE function 141, the only I/O procedure calls permitted against
the file are calls to READX, READUPDATEX, WRITEX, and WRITEUPDATEX. These
procedures can then transfer up to 56K bytes at once.
Transferring Large Buffers Using Nowait I/O
You can perform nowait I/O when large buffers are enabled. However, your program
must not refer to data in the I/O buffer until the I/O operation is complete.
Note. Some Expand connections only support up to 30K bytes of data for a transfer between
extended data segments and a DP2 disk file that has been opened for unstructured access.