View previous topic :: View next topic
|
Author |
Message |
venosol Warnings : 1 New User
Joined: 16 Nov 2006 Posts: 43 Location: Bangalore
|
|
|
|
What is the difference between defining variables in File section and work storage section ?
Thanks and regards
venugopalreddy |
|
Back to top |
|
|
cooldebi
New User
Joined: 19 Apr 2006 Posts: 18 Location: mumbai
|
|
|
|
File-section --> Used to declare properties of a file and records declarations related to the file.
Working storage sections defines all the general variables which are going to be used by the program or by the subroutines called by the program till the program is active in the memory used by CPU. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Here's a primary difference between a data field (in a record) in the FILE section and one in WORKING STORAGE.
If I MOVE values to a record area, then WRITE the record, due to buffering, the internally maintained record pointer is now pointing elsewhere in that file's buffer area, so if I try to reference one of the last written record's fields, or otherwise assume it has retained the value I MOVEd there, it won't have what I MOVEd there.
For this reason, many programmers use a corresponding WORKING STORAGE record area as well, then do the WRITE...FROM verb. This WORKING STORAGE area will retain its values after the WRITE. This is esp. useful if certain values are to be retained for consecutive WRITEs. |
|
Back to top |
|
|
venosol Warnings : 1 New User
Joined: 16 Nov 2006 Posts: 43 Location: Bangalore
|
|
|
|
Now I got idea.
Thanks a lot. |
|
Back to top |
|
|
|