beautypg.com

1 operators and statements – ProSoft Technology MVI56-BAS User Manual

Page 204

background image

BASIC-52 Implementation

MVI56-BAS ♦ ControlLogix Platform

User Manual

BASIC Module (DB/BAS Compatible)

Page 204 of 234

ProSoft Technology, Inc.

December 13, 2011

10.1 Operators and Statements

Operator /
Statement

Description

Example

+

Add

PRINT 1+2

/

Divide

PRINT 4/2

**

Exponentiation

PRINT 2**3

*

Multiply

PRINT 2*3

-

Subtract

PRINT 5-3

-

Negation

PRINT -(5*4)

AND

Bit AND Operator

PRINT 2.AND.3

OR

Bit OR Operator

PRINT 2.OR.3

XOR

Bit XOR Operator

PRINT 2.XOR.3

=

Equal comparison

IF X=3 THEN GOTO 60

>

Greater than

IF X<3 THEN GOTO 60

<

Less than

IF X>3 THEN GOTO 60

<>

Different from

IF X<>3 THEN GOTO 60

SIN()

Returns the sine of argument

PRINT SIN(0)

COS()

Returns the cosine of argument

PRINT COS(0)

TAN()

Returns the tangent of argument

PRINT TAN(0)

ATN()

Returns the arctangent of argument

PRINT ATAN(1)

ABS()

Returns the absolute value of

argument

PRINT ABS(-5)

NOT()

Returns 16 bit complement of

argument

PRINT NOT(3.OR.2)

INT()

Returns the integer portion of

argument

PRINT INT(3.14)

PI

Returns the PI number

PRINT PI

SGN()

Returns 1 if arg >0, -1 if arg<0 and 0 if

arg=0

PRINT SGN(-5)

SQR()

Returns the square root of argument

PRINT SQR(9)

RND

Generates a random number between

0 and 1

PRINT RND

LOG()

Returns the logarithm

PRINT LOG(10)

EXP()

Calculates e

arg

PRINT EXP(1)

ASC()

Returns the integer value of the ASCII PRINT ASC(A)

CHR()

Converts the expression to an ASCII

character

PRINT CHR(32)

CR

LF

GET

Reads the console input device (use
also GET# or GET@ to read from the

ports)

A = GET

LEN

Returns the number of bytes the

current program occupies

PRINT LEN