Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

OPEN DARASET when should BINARY MODE &when in TEXT MODE?

Former Member
0 Likes
1,091

During the OPEN DARASET statement , when should we open a file in BINARY MODE &when in TEXT MODE?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
963

Hi All,

When should we go for BINARY MODE & When should we go for in TEXT MODE?

Could any body give me a clear idea. Which one is default we can use

Binary mode or Text mode.??

Thank you,

Vikram.C

6 REPLIES 6
Read only

Former Member
0 Likes
963

in binary mode, the data is transferred byte by byte

in text mode, the data is transferred line by line

Madhavi

Read only

Former Member
0 Likes
963

Hi,

Binary mode: data will be fetched byte by byte

Text mode: Fetched as line by line.

Read only

Former Member
0 Likes
964

Hi All,

When should we go for BINARY MODE & When should we go for in TEXT MODE?

Could any body give me a clear idea. Which one is default we can use

Binary mode or Text mode.??

Thank you,

Vikram.C

Read only

0 Likes
963

OPEN DATASET <dsn> [Additions].

This statement opens the file <dsn>. If you do not specify any additions for the mode, the file is opened in binary mode for reading.

Read only

0 Likes
963

Hi Dude,

Here is the answer,

To determine whether to open a file “IN TEXT MODE” or “IN BINARY MODE”, you need to know how the file is structured.

If the file is structured in lines (or records), open it “IN TEXT MODE”.

If the file is structured byte-by-byte, open it “IN BINARY MODE”.

These two structure modes affect the processing of sequential files.

With the “TRANSFER” statement:

If you transfer a structure to a file opened “IN TEXT MODE”, the whole structure will be transferred and the system will “mark” the end of the line. On the next transfer, the system will start at the next line.

If you transfer a structure to a file opened “IN BINARY MODE”, the whole structure will be transferred. On the next transfer, the system will start at the next character position.

With the “READ DATASET” statement (see example above):

If you read from a file opened “IN TEXT MODE”, one record of the file will be read into the structure. If the record is shorter than the structure, the structure is padded with spaces. If the record is longer than the structure, the record is truncated. On the next read, the next record is read into the structure.

If you read from a file opened “IN BINARY MODE”, the length of the structure determines how many characters are read. On the next read, the system starts with the next character and again reads as many characters as can fill the structure.

Regards,

Lakshmanan

Read only

Former Member
0 Likes
963

Hi Dude,

To determine whether to open a file “IN TEXT MODE” or “IN BINARY MODE”, you need to know how the file is structured.

If the file is structured in lines (or records), open it “IN TEXT MODE”.

If the file is structured byte-by-byte, open it “IN BINARY MODE”.

These two structure modes affect the processing of sequential files.

With the “TRANSFER” statement:

If you transfer a structure to a file opened “IN TEXT MODE”, the whole structure will be transferred and the system will “mark” the end of the line. On the next transfer, the system will start at the next line.

If you transfer a structure to a file opened “IN BINARY MODE”, the whole structure will be transferred. On the next transfer, the system will start at the next character position.

With the “READ DATASET” statement (see example above):

If you read from a file opened “IN TEXT MODE”, one record of the file will be read into the structure. If the record is shorter than the structure, the structure is padded with spaces. If the record is longer than the structure, the record is truncated. On the next read, the next record is read into the structure.

If you read from a file opened “IN BINARY MODE”, the length of the structure determines how many characters are read. On the next read, the system starts with the next character and again reads as many characters as can fill the structure.

Regards,

Lakshmanan