Application Development 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: 

Does 16 really applies to 4 zeros

Former Member
0 Kudos

Please see this link http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3cf4358411d1829f0000e829fbfe/content.htm

Q] Does 16 really applies to 4 zeros(see output) , & Why should they be multiple of 4 -


Why ? Could you please explain the things .

1 ACCEPTED SOLUTION

Former Member
0 Kudos

For your first question: filling zeros....

The position is defined in bytes, and the start of the file is equal to position 0. If pos contains the value -1, as of release 6.10 the file pointer is positioned at the end of the file. For all other negative values and prior to Release 6.10, the behavior is undefined.

Please note the following special cases:

If the file is opened for reading and the value of pos is greater than the length of the file, the file pointer is positioned outside the file. If the position is not changed, no data can be read. In a non- Unicode program, if a file is opened for reading and is then written to, the file is filled with hexadecimal 0 from the end of the file to the specified position, and the new content is written after that.

If the file is opened for writing, the next time writing takes place, the file is filled with hexadecimal 0 from the start of the file to the specified position, and the new content is written after that.

If the file is opened for appending, the position specification is ignored and the file pointer remains positioned at the end of the file.

If the file is opened for changing, and the value of pos is greater than the length of the file, the next time the file is written in, it is filled with hexadecimal 0 from the end of the file to the specified position, and the new content is written after that.

The addition POSITION cannot be specified if one of the additions FILTER or BYTE-ORDER MARK is specified at the same time.

For your second question: Mulitple by 4.

Yes ... it should be multiple by 4 only. Because it will be hexadecimal (4 bytes). And from the first answer you can remember postion should given in bytes...

4 REPLIES 4

Former Member
0 Kudos

Hi,

In this program..firstly, the cursor was placed at 16 from the start of the file...then it writes 1 till 5 bcoz of the loop statement

DO 5 TIMES.

NUM = NUM + 1.

then the cursor is placed at 28 position to read the contents...i.e 4 and 5...and then 4 and 5 are printed...cursor positions are all multiples of 4 bcoz integer occupies 4 bytes of memory..

reward points if helpful

regards

goutham

Former Member
0 Kudos

For your first question: filling zeros....

The position is defined in bytes, and the start of the file is equal to position 0. If pos contains the value -1, as of release 6.10 the file pointer is positioned at the end of the file. For all other negative values and prior to Release 6.10, the behavior is undefined.

Please note the following special cases:

If the file is opened for reading and the value of pos is greater than the length of the file, the file pointer is positioned outside the file. If the position is not changed, no data can be read. In a non- Unicode program, if a file is opened for reading and is then written to, the file is filled with hexadecimal 0 from the end of the file to the specified position, and the new content is written after that.

If the file is opened for writing, the next time writing takes place, the file is filled with hexadecimal 0 from the start of the file to the specified position, and the new content is written after that.

If the file is opened for appending, the position specification is ignored and the file pointer remains positioned at the end of the file.

If the file is opened for changing, and the value of pos is greater than the length of the file, the next time the file is written in, it is filled with hexadecimal 0 from the end of the file to the specified position, and the new content is written after that.

The addition POSITION cannot be specified if one of the additions FILTER or BYTE-ORDER MARK is specified at the same time.

For your second question: Mulitple by 4.

Yes ... it should be multiple by 4 only. Because it will be hexadecimal (4 bytes). And from the first answer you can remember postion should given in bytes...

0 Kudos

Hi all,

I was bit late. Ramu made it clear that it was filled with hexadecimal zeros.

Thanks

Vadi

i048168
Advisor
Advisor
0 Kudos

Hi,

You are right. Here 16 applies to first 4 zeroes. I think the first 2 bytes 00 00 ( 0 to 15 bits) are initialized values since the position of writing starts with 16. Each character in binary mode is taken as hexadecimal value, so each character takes 4 bits.

I m not sure looking for further postings.

Regards

Vadi