◄Up► ◄Contents► ◄Index► ◄Back► ──────────────────────────────────────────────────────────────────────────── Variables can be shared between source files in the following manner: ┌─TOOLS.INC────────────────┐ │ │ │ EXTERNDEF Global: WORD │◄─Declaration │ COMM Communal: WORD│◄─Declaration & └────────────┬─────────────┘ definition │ ┌────────────────┴─────────────────┐ │ │ ┌─USER.ASM───┴──────────┐ ┌─TOOLS.ASM──┴──────────┐ │ │ │ │ │ INCLUDE TOOLS.INC │ │ INCLUDE TOOLS.INC │ │ │ │ │ │ mov Global, ax │◄┬─Use │ Global WORD ? │◄─Definition │ mov bx, Communal│◄┘ │ │ └───────────────────────┘ └───────────────────────┘ The EXTERNDEF directive in TOOLS.INC declares the variable Global and allows it to be accessed within modules that include TOOLS.INC, such as USER.ASM. The EXTERNDEF directive does not define Global; it is created by TOOLS.ASM. If TOOLS.INC is included by a module that does not use Global, the linker will not import Global. The COMM directive in TOOLS.INC declares and defines the variable Communal and exports it to all modules that include TOOLS.INC, regardless of whether or not Communal is used. -♦-