30.8.4 Nesting Function Blocks

Using a Function Block (FB) within another FB's program is called "nesting FBs." You can nest FBs up to 16 levels. However, you cannot use recursive calls (using an FB as an instruction within the same FB).

*1. Recursive call from the first instance of FB_0000

*2. The 17th level (nesting is allowed up to 16 levels)

Registering Nested FB as a Package

When registering a nested FB as a package, you can select whether or not to register the FBs used as instructions together in the package.

When you drag and drop a nested FB to a package, a dialog box appears with a list of FBs used as instructions. Select the FBs to include in the same package, and click [OK].

For example, you are registering FB_0 to a package, and FB_1 is used as an instruction in FB_0.

The program for FB_1, which is used as an instruction, is also registered in the package at the same time. When you unpack FB_0, both, FB_0 and FB_1 are added to the Screen List. You can use the unpacked FB_0's logic program without modification.

In FB_0, the instruction portion where it is calling FB_1 remains, but the FB_1 itself (logic program) does not exist. When you unpack FB_0, FB_0 is added to the Screen List, but FB_1, which is called in the program, doesn't exist. In order for FB_0 to work properly, you need to create FB_1 again.