| **Navigation:**  [[introduction.htm|Language Reference]] > 13 - Built-in Functions >====== CHAIN (execute another program) ====== | [[center return centered string .htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[change change control field value .htm|{{btn_next_n.gif|Next page}}]] | | || ** ** **CHAIN(**//program//**)** {{blk2blue.jpg|blk2blue.jpg}} | **CHAIN** | Terminates the current program and executes another. | | //program// | A string constant or variable containing the name of the program and optional command line parameters to execute. This may be any .EXE or .COM program. | **CHAIN** terminates the current program, closing all files and returning its memory to the operating system, and executes another //program//. **Example:** ** PROGRAM                          !MainMenu program code** ** CODE** ** EXECUTE CHOICE()** ** ****CHAIN****('Ledger')                 !Execute LEDGER.EXE** ** ****CHAIN****('Payroll ****/Test=1 /N=2****')   !Execute PAYROLL.EXE with parameters** **  RETURN                          !Return to O/S** ** END** **  PROGRAM                         !Ledger program code** ** CODE** ** EXECUTE CHOICE()** ** ****CHAIN****('MainMenu')               !Return to MainMenu program** **  RETURN                          !Return to O/S** ** END** ** PROGRAM                          !Payroll program code** ** CODE** ** EXECUTE CHOICE()** ** ****CHAIN****('MainMenu')               !Return to MainMenu program** **  RETURN                          !Return to O/S** ** END** **See Also:** [[run execute command .htm|RUN]]