Introduction

Add to My manuals
704 Pages

advertisement

Introduction | Manualzz

Expressions

Structured Text Programming Appendix C

Assign an ASCII character to a string

Use the assignment operator to assign an ASCII character to an element of the

DATA member of a string tag. To assign a character, specify the value of the character or specify the tag name, DATA member, and element of the character. For example:

This is OK

string1.DATA[0]:= 65; string1.DATA[0]:= string2.DATA[0];

This is not OK.

string1.DATA[0] := A; string1 := string2;

To add or insert a string of characters to a string tag, use either of these ASCII string instructions:

To

add characters to the end of a string insert characters into a string

Use This Instruction

CONCAT

INSERT

An expression is a tag name, equation, or comparison. To write an expression, use any of the following:

• tag name that stores the value (variable)

• number that you enter directly into the expression (immediate value)

• functions, such as: ABS, TRUNC

• operators, such as: +, -, <, >, And, Or

As you write expressions, follow these general rules:

Use any combination of upper-case and lower-case letter. For example, these three variations of "AND" are acceptable: AND, And, and.

For more complex requirements, use parentheses to group expressions within expressions. This makes the whole expression easier to read and ensures that the expression executes in the desired sequence. See

“ Determine the order of execution “on page 669 .

Publication 1756-RM003K-EN-P - July 2008

Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com

663

Appendix C Structured Text Programming

In structured text, you use two types of expressions:

BOOL expression

: An expression that produces either the BOOL value of 1

(true) or 0 (false).

A bool expression uses bool tags, relational operators, and logical operators to compare values or check if conditions are true or false.

For example, tag1>65.

A simple bool expression can be a single BOOL tag.

Typically, you use bool expressions to condition the execution of other logic.

Numeric expression

: An expression that calculates an integer or floating-point value.

A numeric expression uses arithmetic operators, arithmetic functions, and bitwise operators. For example, tag1+5.

Often, you nest a numeric expression within a bool expression. For example, (tag1+5)>65.

Use the following table to choose operators for your expressions:

If You Want To

Calculate an arithmetic value

Compare two values or strings

Check if conditions are true or false

Compare the bits within values

Then

“ Use arithmetic operators and functions “on page 665 .

“ Use relational operators “on page 666 .

“ Use logical operators “on page 668 .

“ Use bitwise operators “on page 669 .

664

Publication 1756-RM003K-EN-P - July 2008

Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com

advertisement

Related manuals

advertisement

Table of contents