From: David E. <de...@us...> - 2009-01-14 12:53:51
|
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. However you can use qualification to achieve a similar effect. Example: ... 01 NAME-A. 05 INT-A PIC S9(8). 05 INT-B PIC S9(8). 01 NAME-B. 05 INT-A PIC S9(8). 05 INT-B PIC S9(8). ... MOVE INT-B OF NAME-A TO INT-A OF NAME-B. > I found documentation of LINKAGE section in IBM web. > Well I can define the data structure in LINKAGE section and next rewrite > address of this structure to any other address, but it's too > intricately. > First I must acquire lenght of structure, allocate memory, until I can > rewrite the address. > > Any other ideas, how can I do it in tiny cobol? I don't understand what you are trying to accomplish. In any case TC does support the following. Pointers to a limited extent. Example: ... 01 NAME-P POINTER. ... SET idetifier-1 TO ADDRESS OF idetifier-2. Length of identifiers. Example: ... 01 INT-A PIC S9(4). ... MOVE LENGTH OF idetifier-1 TO idetifier-2 Dynamic memory allocation is not supported in TC (COBOL 85 standard). I think it was introduced in the COBOL 2002 standard. Hope this helps. HINT: You can find some examples on how to mix COBOL/C/COBOL programs in the 'test.code' directories of the source code. |