Add New Subroutine

Topic: CL070

Description

Subroutines can be created to isolate a body of code that is run selectively from the Main Program using the Call instruction. Subroutine Programs are created and named using the New Subroutine Program dialog, which is accessed from the Program Menu,by using the Ctrl + U keyboard shortcut, or by right-clicking on an existing subroutine in the Navigation Panel. You can have up to 986 Subroutine Programs in a CLICK project. To insert the Call instruction into the ladder program, a Subroutine Program must be created. Even if you only create a named Subroutine Program with a blank ladder, this will provide the Name of the Subroutine Program so the Call instruction can be inserted into the ladder program. (See below)

New Subroutine Dialog

Create a  Subroutine Program using this dialog. The name can be a maximum of 24 characters long. Click OK to create the Subroutine Program and open the Ladder Editor to the new program.

Quick Guide

Before the Subroutine Program opens, first time users of CLICK Subroutines will encounter the Quick Guide for Subroutines, which contains important information about Subroutines.

Note: The background color of the Subroutine Program is different from the Main Program or Interrupt Programs to alert the programmer that the Subroutine Program is the active program. To customize the colors of the Ladder Editor, look at  Software Setup Color.

To View Subroutine Programs

The Subroutine Program just created or any existing Subroutine Program can be viewed by clicking on the Subroutine Program selection of the Program Tree located on the left panel of the screen as shown below. When selected, the tree will expand and display any existing Subroutine Programs.

Switch Between Programs

To return to the Main Program, use the Window Menu and select Main Program. Also visit the Window Menu to Tile or CascadeProgram Windows.

No Subroutine Selected


If a Subroutine has not been created, the Call instruction cannot be placed in the ladder program. This message will appear.

Related Topics:

Quick Guide Subroutine
Call Instruction
Return