What is the purpose of using SYNC in COBOL?

4 posts / 0 new
Last post
Anonymous
What is the purpose of using SYNC in COBOL?

Can someone explain the purpose of using SYNC in COBOL?

 

Thanks

Anonymous
Use of SYNC In cobol

SYNC is used for faster computations...

it creates slack bytes(unused space).....

Ex:

01 ws-var s9(04) comp

it starts from 3rd byte.

01 ws-var s9(04) comp sync

it starts from 4th byte...

 

Thanks&Regrads,

vijay

Anonymous
SYNC sets storage boundary

SYNC sets storage boundary alignment for the variable you are defining.  Firstly 01 and 77 level variables are always aligned on a double-word boundary (0, 8, 16, 24...) and level variable after the 01 begins on the next byte position, except if SYNC is specified.  A 9(4) COMP variable is aligned to the next half-word, a 9(8) COMP is aligned to the next full-word, and COMP-1/COMP-2 variables are aligned to the next double-word boundary.

Offline
Joined: 12/26/2011 - 06:34
SYNC in COBOL

As previously explained, sets a storage boundary - re-read the earlier explanaton.

Slack is the bytes "left over" from some field to the next boundary aligned (SYNCed) field.

To see this, suggest you create some code with various short field that are 01 levels as well as some lower levels. Look at the compiled output to see how the compiler aligns things. Then add a few more lower level field (01s are automatically aligned)) and specify SYNC and see the results.

Log in or register to post comments
Sponsored Listing