How S7-SCL Sources Generate Blocks and Use Compilation Control Files in STEP 7 Classic

How S7-SCL Sources Generate Blocks and Use Compilation Control Files in STEP 7 Classic

In classic STEP 7 for S7-300/400, an S7-SCL source file is the editable text program; compiling it generates executable blocks in the S7 program's Blocks folder. The generated block is not the source itself, so opening it through the S7-SCL editor opens its associated source when that source is available. A compilation control file batches multiple SCL source files and lists the order in which the compiler processes them, which is useful when types and called blocks have dependencies.

Table of Contents

Source file, compiled block and Blocks folder

An S7-SCL source file contains textual declarations and program code for one or more blocks and user-defined data types. Compilation translates that source into STEP 7 blocks and stores them in the program's Blocks folder. Keep the source as the maintainable version: Siemens advises making changes in the SCL source and recompiling, rather than editing the compiled block's STL/MC7 representation.

Why opening the block returns to the source

For S7-SCL V5.3, Siemens documents that the S7-SCL application opens the corresponding source, not the compiled block. A compiled SCL block can be viewed through the LAD/STL/FBD editor in STL representation, but Siemens cautions against modifying that representation: it may not be valid STL, it can change the block's language identifier, and it can leave the source and compiled code inconsistent. If the associated source is missing, the original readable SCL logic cannot be recovered merely by opening the compiled block.

Compile one SCL source file

In the S7-SCL editor, save the source and compile it with File > Compile. Siemens' V5.3 manual notes that object-code generation must be enabled to create executable blocks and that the corresponding symbol table should be in the program folder when symbols are used. Review the Errors and Warnings window; an error prevents block compilation. These menu names and options apply to the cited S7-SCL V5.3 classic toolchain.

When to use a compilation control file

A compilation control file compiles multiple S7-SCL source files in a specified order within a source folder. It is useful for repeatable batch builds when one source depends on types or blocks created by another. It automates a defined compilation sequence; it does not itself design dependencies or prove that the resulting program is correct.

Create and run a compilation control file

  1. In the S7 program's source files folder, choose File > New.
  2. Select the object type S7-SCL Compilation Control File and name the file.
  3. Enter the S7-SCL source-file names in the order they must be compiled, then save the control file.
  4. Select File > Compile to compile the listed sources in sequence.
  5. Review compilation errors and warnings for each file, correct errors in the source, and compile again.

Use the interface provided by the installed S7-SCL version; the exact dialog labels may differ between releases.

Choose a dependency order

The S7-SCL V5.3 manual specifies that called blocks must precede calling blocks, UDTs must precede blocks that use them, and shared data blocks must precede blocks that access them. For example, if block AA calls BB, compile BB before AA; if BB uses a user-defined type, ensure that type is compiled/available before BB. A control file is most useful when it records this order consistently.

Version and project limits

The supporting Siemens manual is S7-SCL V5.3 for S7-300/400. The source does not identify its PCS 7 or S7-SCL version. Do not assume the same editor workflow, file format or language features apply to TIA Portal SCL or another compiler. Use the documentation for the installed S7-SCL version and target CPU.

Verification

After compilation, check the compiler report, confirm expected blocks and data types are present in the Blocks folder, and use the appropriate STEP 7 consistency checks where source/block interfaces have changed. A successful compile only confirms the compiler accepted that build; validate program behavior under the project's normal review and test process before download.

Limitations and Operational Precautions

The source does not provide the engineer's PCS 7 release, S7-SCL version or code, so no syntax example or CPU-specific runtime claim is included. Changes to block interfaces or shared types can affect callers and instance data. Review the dependency chain and normal download safeguards before transferring changed blocks to a controller.

Engineer FAQ

Why does the SCL editor show source when I open a compiled FB? In S7-SCL V5.3, the SCL editor opens the associated source; it does not open the compiled block's native code view.

Where does a compiled block appear? Siemens documents compiled SCL blocks in the S7 program's Blocks folder.

What does the compilation control file do? It lists multiple SCL source files to compile sequentially in a specified order.

What should come first in the compilation order? UDTs and called/shared dependencies must precede the blocks that use them; callers compile after called blocks.

Can I edit the SCL-generated block in STL instead? Siemens warns this can desynchronize the source and compiled block and change the block's language identifier; maintain the source and recompile instead.

Technical References

  • Siemens, S7-SCL V5.3 for S7-300/400, Programming Manual, A5E00324650-01, §§4.4.4 “Opening Blocks,” 4.7.3–4.7.4 “Compiling the Program” and “Creating a Compilation Control File,” and §4.5.2 “Order of the Blocks”: https://cache.industry.siemens.com/dl/files/793/5581793/att_66783/v1/SCL_e.pdf

Related Articles

Related Tags

20 respuestas