• No results found

Editing in SCL Source Files

4 Using SCL

4.6 Editing in SCL Source Files

4.6.1 Undoing the Last Editing Action

With the menu command Edit> Undo, you can reverse one or more actions.

You cannot reverse all actions. As an example, the menu command File >Save cannot be reversed.

4.6.2 Redoing an Editing Action

After you have reversed one or more actions, you can restore the reversed actions with the menu command Edit> Redo.

S7-SCL V5.3 for S7-300/400

4-10 A5E00290611-01

4.6.3 Finding and Replacing Text Objects

If you want to edit or modify an SCL source file, you can often save valuable time by searching for text objects and replacing them. You can search, for example, for keywords, absolute identifiers, symbolic identifiers etc.

Follow the steps outlined below:

1. Select the menu command Edit > Find and Replace....

2. Enter the options in the "Find and Replace" dialog box.

3. Start the search as follows:

- Click the "Find" button to find a text object and to mark it or

- Click the "Replace" or "Replace All" button to find a text and replace it by the text entered in the "Replace with" text box.

4.6.4 Selecting Text Objects

You can select text objects by holding down the mouse button and dragging the mouse pointer over the selected area of text.

You can also:

• Select the complete source text by selecting the menu command Edit> Select All.

• Select a word by double-clicking on it.

• Select an entire line by clicking in the margin to the left of the line.

With the menu command Edit > Undo Selection, you can cancel the selection.

4.6.5 Copying Text Objects

With this function you can copy entire programs or sections of them. The copied text is placed on the clipboard and can then be pasted as often as you require at other points in the text.

Follow the steps outlined below:

1. Select the text object to be copied.

2. Copy the object as follows:

- Click the "Copy" button in the toolbar or - Select the menu command Edit > Copy.

3. Move the cursor to the point at which you want to paste the object (in the same or in a different application).

4. Paste the object as follows:

- Click the "Paste" button in the toolbar or - Select the menu command Edit > Paste.

4.6.6 Cutting Text Objects

With this function, you place the selected text on the clipboard. Normally, this menu command is used in conjunction with the menu command Edit > Paste that inserts the content of the clipboard at the position currently marked by the cursor.

Follow the steps outlined below:

1. Select the object you want to cut.

2. Cut the object as follows:

- Click the "Cut" button in the toolbar or - Select the menu command Edit > Cut.

Note

The selected object cannot be cut if the menu command Edit > Cut is not activated (on a gray background).

Using the menu command Edit > Paste, you can insert the text you have cut at any point (in the same or in a different program).

The content of the clipboard is retained until you use one of the menu commands Edit

> Cut or Edit > Copy again.

4.6.7 Deleting Text Objects

You can delete a selected text object from the source text.

Follow the steps outlined below:

1. Select the text you want to delete.

2. Select the menu command Edit > Delete.

The deleted text is not copied to the clipboard. The deleted object can be retrieved with the menu command Edit > Undo or Edit > Redo.

4.6.8 Positioning the Cursor in a Specific Line

With this function you can position the cursor at the start of a particular line.

Follow the steps outlined below:

1. Open the "Go To" dialog box by selecting the menu command Edit > Go To Line.

2. Type in the line number in the "Go To" dialog box.

3. Confirm with "OK".

S7-SCL V5.3 for S7-300/400

4-12 A5E00290611-01

4.6.9 Syntactically Correct Indenting of Lines

The following functions allow you to structure SCL source files by indenting lines.

Automatic indent

When this function is active, the new line following a line break is automatically indented by the same amount as the previous line.

Indenting keywords

When this function is active, lines in the declaration sections and within the control structures IF, CASE, FOR, WHILE and REPEAT are indented.

Follow the steps outlined below:

1. Select the Options > Customize menu command.

2. Select the "Format" tab in the dialog displayed.

3. Make sure that the option "Use following formats" is active.

4. Activate the option "Indent automatically" or "Indent keywords".

4.6.10 Setting the Font Style and Color

The use of different styles and colors for the various language elements makes an SCL source file easier to read and lends it a more professional appearance. To format the source text, you can use the following functions:

Keywords in uppercase:

When this function is active, defined keywords such as FOR, WHILE, FUNCTION_BLOCK, VAR or END_VAR are written in uppercase letters.

Defining the style and color:

There are various default styles and colors for the various language elements such as operations, comments or constants. You can change these default settings.

The following colors are the defaults:

Font Color Language Element Example

Blue Keywords ORGANIZATION_BLOCK

Predefined data types INT

Predefined identifiers ENO

Standard functions BOOL_TO_WORD

Ochre Operations NOT

Pink Constants TRUE

Blue-green Comments //... or (*...*)

Violet Shared symbols (symbol table) inside quotes "Motor"

Black Normal text Variables

Follow the steps outlined below:

1. Select the Options > Customize menu command.

2. Select the "Format" tab in the dialog displayed.

3. Make sure that the option "Use following formats for printing:" is enabled.

4. You can now make the required settings. You can display detailed information about the dialog box by clicking the "Help" button while the dialog is open.

4.6.11 Inserting Templates 4.6.11.1 Inserting Block Calls

SCL supports you when programming block calls. You can call the following blocks:

• System function blocks (SFB) and system functions (SFC) from the SIMATIC libraries,

• Function blocks and functions created in SCL,

• Function blocks and functions created in other STEP 7 languages.

Follow the steps outlined below:

1. Select the Insert > Block Call menu command.

2. Select the required SFC, SFB, FC, or FB in the dialog box and confirm your selection with "OK".

SCL copies the called block automatically to the S7 program and enters the block call and the formal parameters of the block with the correct syntax into the source file.

3. If you call a function block, add the information about the instance DB.

4. Enter the actual parameters required by the block. To help you select an actual parameter, SCL indicates the required data type as a comment.

4.6.11.2 Inserting Block Templates

One SCL editing function allows you to insert block templates for OBs, FBs, FCs, instance DBs, DBs, DBs that reference UDTs, and UDTs. Using these block templates makes it easier to program and to keep to the required syntax.

Follow the steps outlined below:

1. Position the cursor at the point at which you want to insert the block template.

2. Select the menu command Insert > Block Template > OB/FB/FC/DB/IDB/DB Referencing UDT/UDT.

S7-SCL V5.3 for S7-300/400

4-14 A5E00290611-01

4.6.11.3 Inserting Templates for Comments

This SCL editing function allows you to insert templates for comments. Using these templates makes it easier to input your information and to keep to the required syntax.

Follow the steps outlined below:

1. Position the cursor after the block header of the required block.

2. Select the menu command Insert > Block Template > Comment.

4.6.11.4 Inserting Parameter Templates

One SCL editing function allows you to insert templates for the declarations of the parameters. Using these templates makes it easier to type in your program and to keep to the required syntax. You can declare parameters in function blocks and in functions.

Follow the steps outlined below:

1. Position the cursor in the declaration section of an FB or FC.

2. Select the menu command Insert > Block Template > Parameter.

4.6.11.5 Inserting Control Structures

This SCL editing function allows you to insert control structure templates for logic blocks. Using these templates makes it easier to input your information and to keep to the required syntax.

Follow the steps outlined below:

1. Position the cursor at the point at which you want to insert the template.

2. Select the menu command Insert > Control Structure >

IF/CASE/FOR/WHILE/REPEAT.