Use Coupon: CART20 and get 20% off on all online Study Material

Total Price: Rs.

There are no items in this cart.
Continue Shopping
Vijay Panchal Grade: Upto college level

What is modular programming??

8 years ago

Answers : (1)

Deepak Patra
askIITians Faculty
474 Points

Modular programming can be used to break up a large program into manageable units, or to create code that can be easily re-used.  A modular program consists of a main module and one or more auxiliary modules.  Each module originates from a separate source code file.  The main module is compiled as an EXE, and calls functions in the auxiliary modules.  The auxiliary modules can be dynamically linked, meaning they exist as separate executable files (DLLs) which are loaded when the main EXE is run; or they can be statically linked, meaning they are compiled as object files or static libraries (LIBs) that are combined with the main module into a single executable file.

Once you have learned how to create an executable file from an XBasic source program, it is easy to extend the procedure to make dynamically linked modules and (a little less easily) statically linked modules.  There are, however, a few rules that must be followed when writing the source code for the auxiliary modules.

Each module must have a unique name, assigned in the PROGRAM statement.  This name must be the same as the file name of the source code, minus the .x extension.  For example, the source code auxiliary.x must have the statement PROGRAM "auxiliary" in the PROLOG.  (The standard PROLOG code contains the comment that the program name must have 1 to 8 characters, but names longer than this seem to work without any problem.  However, the name cannot contain spaces.)

Function names need to be unique across all modules (with the exception of INTERNAL FUNCTIONs).  This includes the Entry() function, which will need to be renamed in each auxiliary module.  After re-naming the Entry() function, be sure to edit the PROLOG so that the new name is the first declared function.  See below for more notes on the Entry function.

All functions, composite types, and global constants that will be used by the main module (or by another auxiliary module) must be exported - ie., enclosed in an EXPORT...END EXPORT block in the PROLOG.

EXTERNAL variables can be used in statically linked modules, but not in DLLs.  Such variables are shared only within a single executable module, and since all statically linked modules are combined with the main module into a single EXE, EXTERNAL variables can be shared between them.  A DLL remains separate from other modules, and does not share EXTERNAL variables with them.

8 years ago
Think You Can Provide A Better Answer ?
Answer & Earn Cool Goodies
  • Complete AIPMT/AIIMS Course and Test Series
  • OFFERED PRICE: Rs. 15,900
  • View Details
Get extra Rs. 3,180 off
  • Complete JEE Main/Advanced Course and Test Series
  • OFFERED PRICE: Rs. 15,900
  • View Details
Get extra Rs. 3,180 off

Ask Experts

Have any Question? Ask Experts

Post Question

Answer ‘n’ Earn
Attractive Gift
To Win!!! Click Here for details