View previous topic :: View next topic
|
Author |
Message |
sreedharm Warnings : 1 New User
Joined: 12 Mar 2007 Posts: 1 Location: NJ, US
|
|
|
|
Do we have concrete answer for this question?
In COBOL while reading from file we code READ <file name> where as while writing to file we code WRITE <record name>. What is the reason not to use 'file name' at the time of writing also?
Warning: Wrong Forum |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
sreedharm wrote: |
Do we have concrete answer for this question?
In COBOL while reading from file we code READ <file name> where as while writing to file we code WRITE <record name>. What is the reason not to use 'file name' at the time of writing also? |
Simple, a record on a file can have many layouts, especially variable files where not only the layouts might be different but the lengths too.
You READ filename and all the 01s are "available" to be the record definition.
You WRITE recordname primarily to let the output exactly what the record length is.
If this is not concrete enough, let us know and we will try again. |
|
Back to top |
|
|
venosol Warnings : 1 New User
Joined: 16 Nov 2006 Posts: 43 Location: Bangalore
|
|
|
|
sreedharm wrote: |
Do we have concrete answer for this question?
In COBOL while reading from file we code READ <file name> where as while writing to file we code WRITE <record name>. What is the reason not to use 'file name' at the time of writing also?
Warning: Wrong Forum |
WRITE statement occurs after READ statement only. So there is no need to again mention filename. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Venu,
Quote: |
WRITE statement occurs after READ statement only |
Are you sure about this? |
|
Back to top |
|
|
venosol Warnings : 1 New User
Joined: 16 Nov 2006 Posts: 43 Location: Bangalore
|
|
|
|
murmohk1 wrote: |
Venu,
Quote: |
WRITE statement occurs after READ statement only |
Are you sure about this? |
Ya,
First we need to check the filename whether it contains records or not then only appropriate action should be taken. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Venu,
You need to think much before you write this.
Quote: |
WRITE statement occurs after READ statement only. |
What if I open a file in OUTPUT mode and just WRITE number of records in to it? Think about it and let us know. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Venu,
Quote: |
whether it contains records or not |
What do you mean by this? Do you mean to say we cannot write records into an empty file? Please rethink twice before you post any reply. |
|
Back to top |
|
|
|