Posted: Thu Jun 29, 2006 1:54 am Post subject: file status when subprogram back to main program
Hi all,
I read some post about the external clause and the reference,then I have some idea to confirm:
Quote:
Using external files has these benefits:
Your main program can reference the record area of the file, although the main program does not contain any input or output statements.
Each subprogram can control a single input or output function, such as OPEN or READ.
Each program has access to the file.
Program B could access that data item by having the identical data description in its WORKING-STORAGE SECTION.
1)If I do not defined as EXTERNAL ,then,for example,SUB PROG A open file x,then return to MAIN PROG B without close file,if I want to access file x in B,I must open it again?
2)If B wants to access the external item define in A,then I sould code a variable has the same name and format?For example,A has
01 wk-o pic 9(1) external then in B should code 01 wk-o pic 9(1) ?
And if B call another subprog C,can C use external variable used
in A?Or I should define in B again with external clause again the same as
in A.
Quote:
Using external files has these benefits:
Your main program can reference the record area of the file, although the main program does not contain any input or output statements.
Each subprogram can control a single input or output function, such as OPEN or READ.
Each program has access to the file.
3) For red item,Does that means one subprog can only have one function??
For question 2),rectified,My understand is : 'External' means put the VARIABLE into a common area,then any program wants to access this VARIABLE also need to define a VARIABLE EXTERNAL with a same name.A has a external VARIABLE,then
A call B,B do not use it,B call C,C wants to use it, B don't need to define it again,Right?
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum