Pathway/iTS TCP and Terminal Programming Guide

Programming for Intelligent Devices
Compaq NonStop™ Pathway/iTS TCP and Terminal Programming Guide426751-001
6-7
Using Delimited Format With Delimiters Turned Off
Using Delimited Format With Delimiters Turned Off
By declaring a message template to be delimited but turning off both the field and
message delimiters, you can effectively create a new type of variable-length record
format that has no prefix byte count or delimiters.
SCREEN COBOL supports two other types of variable-length message formats, known
as VARYING1 and VARYING2, that include a one-byte or two-byte count field at the
beginning of each message specifying the total number of bytes contained in the
message. The use of delimited format with the delimiters turned off creates a variable-
length message with no count field preceding it.
For all three types of messages, if the message contains variable-length fields, the
structure of the message must include a count field preceding each individual field. This
count-field value allows the receiving device or process to know how long the field is,
because no delimiter is present.
The following Working-Storage Section and Message Section declarations define data
structures and a message template suitable for sending and receiving this new type of
variable-length message.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-RECORD1-COUNT PIC 9(4).
01 WS-RECORD1.
05 WS-RECORD1-DATA PIC X(1)
OCCURS 1 TO 100 TIMES
DEPENDING ON ws-record1-count.
MESSAGE SECTION.
01 msg-format1 PIC X(100) USING ws-record1
MESSAGE FORMAT IS DELIMITED
FIELD-DELIMITER IS OFF
MESSAGE-DELIMITER IS OFF
RESULTING COUNT IS ws-record1-count.
The preceding message template declares that the associated message is of variable
length with a maximum size of 100 bytes, that it includes no count field (such as is
found in a VARYING1 or VARYING2 format record), and that the TCP is to use the
working-storage data item WS-RECORD1-COUNT for storing (on input) or retrieving
(on output) the appropriate record length value.