From: Fred M. <fr...@mo...> - 2009-01-14 17:39:56
|
On Wednesday 14 January 2009 12:57, David Essex wrote: > deu439 wrote: > > Thanks, but I _didnt_ mean structures. > > > > Typedef; can be used for define new data type/structures. > > So I can declare new variable/struct with defined aligment. > > > > Like this: > > > > //define data type "NAME" > > typedef struct{ > > int a; > > int b; > > }NAME; > > > > main(){ > > //declare struct > > //with "NAME" aligment > > NAME declared_struct; > > } > > > > Sorry whether it's too intuitive. > > AFAIK, COBOL (85 standard) does not differentiate between a > declaration and definition (memory allocation). Meaning it does both > in one step. I don't understand the original question of OP, but I would like to add to your statement above. In a WORKING-STORAGE SECTION, declarations allocate memory and declare a memory layout. In a LINKAGE SECTION, declarations don't allocate memory but just declare a memory layout. The memory is in general allocated in the calling program in the WORKING-STORAGE SECTION. Example : PROGRAM-ID. A. <--- Main program. ... WORKING-STORAGE SECTION. <--- allocation and layout. 01 AREA-A-1. 03 FIELD-A-1-A PICTURE X(7). 03 FIELD-A-1-B PICTURE X(3). 01 AREA-A-2. 03 FIELD-A-2-A PICTURE X(7). 03 FIELD-A-2-B PICTURE X(3). 01 AREA-A-3. 03 FIELD-A-3-A PICTURE X(7). 03 FIELD-A-3-B PICTURE X(3). PROCEDURE DIVISION. START SECTION. P00. CALL "B" USING AREA-A-1 AREA-A-3. EOS. STOP RUN. PROGRAM-ID. B. <--- Subroutine. ... LINKAGE SECTION. <--- Only layout per 01 level. 01 AREA-B-1. 03 FIELD-B-1-A PICTURE X(7). 03 FIELD-B-1-B PICTURE X(3). 01 AREA-B-2. 03 FIELD-B-2-A PICTURE X(7). 03 FIELD-B-2-B PICTURE X(3). PROCEDURE DIVISION USING AREA-B-1 AREA-B-2. START SECTION. P00. .... EOS. EXIT PROGRAM. PLease notice that the subroutine B does not know if the arguments AREA-B-1 and AREA-B-2 are located in adjacent area's or not. The main program A knows they're NOT. Often such structures are put in copy members in order to avoid differences in declarations. But that results in another problem : VALUE clauses are (were ?) not allowed in the linkage section. -- Fred Mobach - fr...@mo... - pos...@mo... website : http://fred.mobach.nl .... In God we trust .... .. The rest we monitor .. |