Because of the variety of uses for the products described in this publication, those
responsible for the application and use of this control equipment must satisfy
themselves that all necessary steps have been taken to assure that each application
and use meets all performance and safety requirements, including any applicable
laws, regulations, codes and standards.
The illustrations, charts, sample programs and layout examples shown in this
guide are intended solely for purposes of example. Since there are many variables
and requirements associated with any particular installation, Rockwell
International Corporation does not assume responsibility or liability (to include
intellectual property liability) for actual use based upon the examples shown in
this publication.
Rockwell Automation publication SGI-1.1, Safety Guidelines for the Application, Installation and Maintenance of Solid-State Control (available from your local
Rockwell Automation office), describes some important differences between
solid-state equipment and electromechanical devices that should be taken into
consideration when applying products such as those described in this publication.
Reproduction of the contents of this copyrighted publication, in whole or part,
without written permission of Rockwell Automation, is prohibited.
Throughout this manual we use notes to make you aware of safety considerations:
ATTENTION
Attention statements help you to:
• identify a hazard
• avoid a hazard
• recognize the consequences
IMPORTANT
PLC-5 is a registered trademark; and MicroLogix, SLC 500, RSLogix, and RSLinx are trademarks of Rockwell Automation.
Identifies information about practices or circumstances that
can lead to personal injury or death, property damage or
economic loss
Identifies information that is critical for successful
application and understanding of the product.
Language Elements
Data Types
Expressions and Operators
Table of Contents
Preface
Who Should Use This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . P-1
Read this preface to familiarize yourself with the rest of the manual. This preface
covers the following topics:
• who should use this manual
• the purpose of this manual
• how to use this manual
• terms and abbreviations
• conventions used in this manual
• Rockwell Automation support
Who Should Use This
Manual
Use this manual if you are responsible for designing, installing, programming, or
troubleshooting control systems that use Allen-Bradley small logic controllers.
You should have a basic understanding of SLC 500™ products. You should
understand programmable controllers and be able to interpret the ladder logic
instructions required to control your application. If you do not, contact your local
Rockwell Automation representative for information on available training courses
before using this product.
P-1Publication 1746-RM001 A-US-P
P-2
Purpose of this Manual
This manual is a reference guide for programming the BASIC or BASIC-T
module. This manual is intended for reference purposes only.
ChapterTitleContents
PrefaceDescribes the purpose, background, and scope of this manual. Also lists related
publications.
1Language ElementsDescribes BASIC program lines, line numbers, statements, commands,
operators, and line length.
2Data TypesDescribes and illustrates data types, variable names and types.
3Expressions and OperatorsDescribes and illustrates arithmetic, logical, relational, trigonometric, functional,
logarithmic, string, and special function operators.
4BASIC CommandsDescribes and illustrates BRKPNT, CONT, [CTRL-C], [CTRL-S], [CTRL-Q], EDIT,
ERASE, IDLE, LIST, LIST@, LIST#, MODE, NEW, NULL, PROG, PROG1, PROG2,
RAM, REM, REN, ROM, RROM, RUN, SNGLSTP, VER, and XFER commands and
CALLs 18 and 19.
5Command Line CALLSDescribes and illustrates CALLs 73, 74, 77, 81, 82, 101, 103, 104, 109, 110, and
111.
6Assignment FunctionsDescribes and illustrates CLEAR, CLEARI, CLEARS, DATA, DIM, LET and
RESTORE functions.
7Control FunctionsDescribes and illustrates CLOCK1, CLOCK0, DO-WHILE, DO-UNTIL, END,
FOR-TO-(STEP)-NEXT, GOTO, IF-THEN-ELSE, NEXT, and ON-GOTO functions.
8Execution Control and Interrupt
Support Functions
9Math and Backplane FunctionsDescribes and illustrates CALLs 14, 15, 24, 25, 88, and 89.
10Clock/Calendar FunctionsDescribes and illustrates CALLs 40, 41, 42, 43, 44, 45, 46, 47, 48, and 52.
14Setup FunctionsDescribes and illustrates CALLs 30, 78, 99, 105, 119, and MODE functions.
15String FunctionsDescribes and illustrates CALLs 60, 61, 62, 63, 64, 65, 66, 67, 68, and STRING
Appendix ADecimal/Hexidecimal/Octal/
ASCII Conversion Table
Appendix BBASIC Command, Statement, and
CALL Quick Reference Guide
Describes and illustrates CALLs 16, 17, 20, 21, 26, 38, 70, 71, 72, and GOSUB,
ONERR, ON-GOSUB, ONTIME, PUSH, POP, RETI, RETURN, and STOP functions.
113, 120, and 121.
114, 115, 123, and PRINT, PH0. PH1. and ST@ functions.
and GET, INPL, INPS, INPUT, LD@ and READ functions.
functions.
Lists the Decimal/Hexidecimal/Octal/ASCII equivalents.
Lists the various commands, statements, and CALLs needed for BASIC
programming.
Publication 1746-RM001A-US-P
Related Documentation
The following documents contain additional information regarding Rockwell
Automation products. To obtain a copy, contact your local Rockwell Automation
office or distributor.
ForRead this documentPublication Number
P-3
A BASIC and BASIC-T manual that provides
information on installing and using the 1746-BAS
and 1746-BAS-T modules.
A programming manual with detailed
instructions on installing and using BASIC
Development Software to program the BASIC
and BASIC-T modules.
An overview of the SLC 500 family of productsSLC 500™ System Overview1747-SO001A-US-P
A description of how to install and use a Modular
SLC 500 Processor
A reference manual that contains status file data
and instruction set information for SLC 500
processors
A description of how to install and use a module
that acts as a bridge between DH485 networks
and devices requiring DF1 protocol.
An application example demonstrating how to
transfer ASCII data to an SLC 5/02 or later
processor using a remote SLC 500 BASIC module.
In-depth information on grounding and wiring
Allen-Bradley programmable controllers
A glossary of industrial automation terms and
abbreviations
SLC 500™ BASIC and BASIC-T Modules
User Manual
BASIC Development Software
Programming Manual
Modular Hardware Style Installation and
Operation Manual
SLC 500™ and MicroLogix™ 1000
Instruction Set Reference Manual
DH-485/RS-232C Interface Module User’s
Manual
ASCII Data Transfer to the SLC 500™
BASIC Module (Series B)
Allen-Bradley Programmable Controller
Grounding and Wiring Guidelines
Allen-Bradley Industrial Automation
Glossary
1746-UM004A-US-P
1746-PM001A-US-P
1747-6.2
1747-6.15
1747-6.12
1746-2.41
1770-4.1
AG-7.1
An article on wire sizes and types for grounding
electrical equipment
How to Use this Manual
To use this manual effectively, use the worksheets provided in Appendix B. The
worksheets can help you document your application and settings and also facilitate
the flow of information to other individuals in your organization for
implementation.
National Electric CodePublished by the National Fire Protection
Association of Boston, MA
Publication 1746-RM001A-US-P
P-4
Terms and Abbreviations
The following terms and abbreviations are specific to this product. For a complete
listing of Allen-Bradley terminology, refer to the Allen-Bradley Industrial
Automation Glossary, publication number ICCG-7.1.
• BASIC development software BASIC Development Software (catalog
number 1747-PBASE)
• BASIC —the BASIC-52 programming language
• console device — the device connected to the BASIC module program port.
This device is used as an interface between the user and the BASIC program.
• DH485 network communication protocol
• EPROM Erasable Programmable Read Only Memory
• EEPROM — Electrically Erasable Programmable Read Only Memory
• memory module — BASIC or BASIC-T modules EEPROM or UVPROM
• MTOP system control value that holds the last valid memory address
• program port — the port used to program the module. Either PRT1 or port
DH485 can be used as the program port.
• RAM — Random Access Memory
Conventions Used in this
Manual
• ROM — Read Only Memory, refers to the optional memory module memory
space (EEPROM or UVPROM)
• RS-232/423 serial communication interface
• RS-422 differential communication interface
• RS-485 network communication interface
• SCADA — Supervisory Control and Data Acquisition
• scalar variable — a variable with a single value
• SLC 500 SLC 500 fixed and modular controller
• UVPROM — Ultra Violet Erasable Programmable Read Only Memory
The following conventions are used throughout this manual:
• Bulleted lists such as this one provide information, not procedural steps.
• Numbered lists provide sequential steps or hierarchical information.
• Italic type is used for emphasis.
• Te xt in this font indicates words or phrases you should type.
Publication 1746-RM001A-US-P
• Key names match the names shown and appear in bold, capital letters within
brackets (for example,
[ENTER]).
P-5
Rockwell Automation
Support
Allen-Bradley offers support services worldwide, with over 75 Sales/Support
Offices, 512 authorized Distributors and 260 authorized Systems Integrators
located throughout the United States alone, plus Rockwell Automation
representatives in every major country in the world.
Local Product Support
Contact your local Rockwell Automation representative for:
• sales and order support
• product technical training
• warranty support
• support service agreements
Technical Product Assistance
If you need to contact Rockwell Automation for technical assistance, please review
the information in the appropriate chapter first. Then call your local Rockwell
Automation representative.
Your Questions or Comments on this Manual
If you find a problem with this manual, please notify us of it on the enclosed
Publication Problem Report.
If you have any suggestions for how this manual could be made more useful to you,
please contact us at the address below:
Rockwell Automation
Control and Information Group
Technical Communication, Dept. A602V
P.O. Box 2086
Milwaukee, WI 53201-2086
Publication 1746-RM001A-US-P
P-6
Publication 1746-RM001A-US-P
Chapter
1
Language Elements
This chapter introduces you to the elements of a BASIC program. These elements
include BASIC:
• line numbers
• statements, commands, and operators
• line length
Character Set
The BASIC Program Line
BASIC programs are composed of a group of BASIC program lines. Each BASIC
program line is composed of a group of ASCII characters. Refer to Appendix A for
a complete listing of ASCII character codes.
BASIC program lines consist of a BASIC line number and BASIC statements and
operators. BASIC program lines are restricted to the BASIC line length.
BASIC Line Numbers
We refer to BASIC line numbers as:
[ln num]
BASIC line numbers indicate the order that the program lines are stored in
memory and are also used as references when branching and editing. This number
may be any whole integer from 1 to 65535. Typically you start numbering BASIC
programs with line number 10 and increment by 10. This allows you to add
additional lines later as you work on your program.
Since the computer runs the statements in numerical order, additional lines need
not appear in consecutive order on the screen. If you enter line 35 after line 40, the
computer still runs line 35 after line 30 and before line 40. This technique saves
you from reentering an entire program if you forget to include a line.
IMPORTANT
1Publication 1746-RM001A-US-P
The first line of your program must be a comment.
1-2 Language Elements
Typically, the line numbers of a program start out looking like the first column and
end up looking something like the second column below:
#1#2
105
207
3010
4015
5020
6030
7035
8040
..
..
..
IMPORTANT
Reuse of an existing line number causes all of the information
referenced by the original line number to be lost. Be careful
when entering numbers in the Command mode, as you may
accidentally erase some program lines. You may delete an
existing line by retyping it with no information following it and
pressing
[RETURN].
BASIC Statements, Commands, and Operators
BASIC program lines consist of a BASIC line number and BASIC statements and
operators. Depending on the logic of your program, there may be more than one
statement on a line. If so, each must be separated by a colon (:).
BASIC Line Length
A BASIC program line always begins with a line number and must contain at least
one character, but no more than 68 characters. A program line ends when you press
[RETURN].
Publication 1746-RM001A-US-P
Chapter
Data Types
This chapter provides you a method of defining or displaying data within the
BASIC programming language through the use of:
• data types
• variables
2
Data Types
Data types are broken down into three sections: argument stack, string and
numeric elementary data types, and backplane conversion data.
Argument Stack
The argument stack (A-stack) stores all constants that the BASIC or BASIC-T
module is currently using. Operations such as add, subtract, multiply, and divide
always operate on the first two numbers of the argument stack and return the result
to the stack. The argument stack is 203 bytes long. Each floating point number
placed in the stack requires 6 bytes of storage. The argument stack can hold up to
33 floating point numbers before overflowing.
In addition, the PUSH command saves data to the argument stack and the POP
command restores data from the stack. PUSHes and POPs are typically associated
with CALLs. PUSHes and POPs are mechanisms used to transfer information to
and from CALL routines.
PUSH makes a copy of the variable being PUSHed, then puts that copy on the top
of the argument stack. POP takes the value on the top of the argument stack and
copies it to the variable being POPped.
String Data Types
A string is a character or group of characters stored in memory. Usually, the
characters stored in a string make up a word or a sentence. Strings allow you to use
characters instead of numbers. Strings are shown as:
$([expr])
The module uses single-dimension string variables,
a string variable (the
define and manipulate 255 different strings in the module. Initially, no memory is
allocated for strings. Memory is allocated using the STRING statement. Strings are
declared and manipulated through the $ operator.
1Publication 1746-RM001A-US-P
[expr] value) ranges from 0 to 254. This means that you can
$([expr]). The dimension of
2-2 Data Types
When allocating memory for a string, you must account for the overhead bytes
used by BASIC to manipulate strings. BASIC uses one overhead byte per string
being declared plus one additional overhead byte.
Example 1
String 106,20
Allocates space for five 20 byte strings (100 bytes) and includes five overhead bytes
(1 per string) and one additional overhead byte.
In the module you can define strings with the LET statement, the INPUT
statement, and with the ASC operator.
Example 2
>10 STRING 106,20
>20 $(1)=“THIS IS A STRING, ”
>30 INPUT “WHAT’S YOUR NAME? - ”,$(2)
>40 PRINT $(1),$(2)
>50 END
READY
>RUN
WHAT’S YOUR NAME? - FRED
THIS IS A STRING, FRED
READY
>
You can also assign strings to each other with a LET statement.
Example 3
LET $(2)=$(1)
Result: Assigns the string value in $(1) to the STRING $(2).
Publication 1746-RM001A-US-P
Data Types 2-3
Numeric Data Types
There are two different numeric data types:
• integer numbers
• floating-point numbers
You can enter and display numbers in four formats: integer, decimal, hexadecimal,
and exponential.
Example
129, 34.98, 0A6EH, 1.23456E+3
The BASIC or BASIC-T module interprets all numbers as floating-point numbers
except when performing logical operations. When performing logical operations,
the module converts floating-point numbers to integers, performs the operation,
then converts the result back to floating-point.
Integer Numbers
The module operates on unsigned 16-bit integers that range from 0 to 65535 or
0FFFFH. You can enter all integers in either decimal or hexadecimal format. You
indicate a hexadecimal number by placing the character H after the number
(example: 170H). If the hexadecimal number begins with A through F, then it
must be preceded by a zero. (For example, you must enter A567H as 0A567H.)
When an operator, such as .AND. requires an integer, the module truncates the
fraction portion of the number so it fits the integer format. Integers are shown as:
[integer]
IMPORTANT
The SLC 500 processor operates on signed 16-bit integers that
range from –32768 to 32767. If an integer value larger than
32767 is passed to the processor from the module, that value is
interpreted as negative by the processor.
Floating-Point Numbers
In the module, all numbers are stored as floating-point numbers. Floating-point
numbers are numbers in which the decimal point floats depending on the
significant digits of a specific number. The processor accounts for the location of
the decimal point. This allows the processor to store only the significant digits of a
value, thus saving memory space.
You can represent the following range of numbers in the module:
+1E –127 to +.99999999 +127
There are eight significant digits. Numbers are internally rounded to fit this
precision.
Publication 1746-RM001A-US-P
2-4 Data Types
Backplane Conversion Data
The module communicates with the local processor through the SLC 500 I/O
backplane. All data communicated to and from the SLC 500 is in SLC 500 format.
The SLC 500 formats are:
• 16-bit signed integer (–32768 to 32767)
• 16-bit binary (0000000000000000 to 1111111111111111)
Variables
IMPORTANT
Variables that include a single-dimension expression [exp] are dimensioned or
arrayed variables. Variables that contain a letter or a letter and a number are scalar
variables. Any variables entered in lower case are changed to upper case. Variables
are shown as:
[var]
The module allocates variables in a static manner, which means the first time a
variable is used, the module allocates a portion of memory (8 bytes) specifically for
that variable. This memory cannot be de-allocated on a variable to variable basis.
This means that if you execute a statement (example: >10 Q - 3), you cannot tell
the module that the variable Q no longer exists to free up the 8 bytes of memory
that belong to Q. You can clear the memory allocated to variables by executing a
CLEAR statement. The CLEAR statement frees all memory allocated to variables.
Variables may be set aside for reuse to save memory.
IMPORTANT
Any integer larger than 32767 is interpreted as a negative number
by the SLC 500 processor
The module requires less time to find a scalar variable because
there is no expression to evaluate. To run a program as fast as
possible, use single-dimension variables only when necessary. Use
scalar variables for intermediate variables and assign the final
result to a dimensioned variable. Also, put the most frequently
used variables first. Variables defined first require the least
amount of time to locate.
Publication 1746-RM001A-US-P
Data Types 2-5
Variable Names
Variables may represent either numeric values or strings. Variable names can only
be eight characters long. The module compares the first, last, and number of
characters in a variable name with the first, last, and number of characters in other
variable names to determine if it is a unique variable name. The characters allowed
in a variable name are letters, numbers, and the decimal point. Special type
declaration characters are also allowed.
• number followed by a single-dimension expression (example: A1(8),
P7(10*SIN(X)), W8(A + C))
• number (0 to 9) or letter (example: AA, AC, XX, A1, X3, G8) except for the
following combinations:
IMPORTANT
Reserved words (words already used in BASIC functions or
statements) cannot be used as variable names.
CR, DO, IE, IF, IP, ON, PI, SP, TO, UI, UO
Variable Types
Type declaration characters indicate what a variable represents. The following type
declaration character is recognized:
CharacterVariable Type
$String variable
The only other legal variable type is a floating-point variable. Floating-point
variables do not require a type declaration.
Publication 1746-RM001A-US-P
2-6 Data Types
Publication 1746-RM001A-US-P
Chapter
3
Expressions and Operators
This chapter describes and illustrates how you manipulate and/or evaluate
expressions and statements within the BASIC program or the command line. Table
3.1 lists the corresponding mnemonics.
Table 3.1 Chapter Reference Guide
If you need (to)Use this mnemonic Page
Absolute valueABS( )3-9
Return the integer value of the ASCII character.ASC( )3-12
Return the arctangent of the argument.ATN( )3-8
Retrieve data from the specified memory address.CBY( )3-16
Count the value converted ASCII character.CHR( )3-14
Return the cosine of argument.COS( )3-8
Retrieve or assign data to or from the internal data memory of
the BASIC or BASIC-T module.
Test for empty input buffer.EOF3-15
“e” (2.7182818) TO THE XEXP( )3-11
Test for number of free bytes of RAM memory. FREE3-15
IntegerINT( )3-10
Read the number of bytes of memory in the current selected
program.
Natural logLOG( )3-11
Read the last valid memory address.MTOP3-16
One’s complementNOT( )3-9
PI-3.1415926PI3-10
Random numberRND3-11
SignSGN3-10
Return the sine of the argumentSIN( )3-8
Square RootSQR( )3-10
Return the tangent of the argument.TAN( )3-8
Retrieve and/or assign the free running clock value.TIME3-17
Retrieve or assign data to or from the external data memory of
Logical Exclusive OR.XOR.3-6
Direct communications to port PRT1.@3-15
Direct communications to port PRT2.#3-15
Expressions and
Operators
An expression is a logical mathematical expression that involves operators,
constants, and variables. There are eight types of operators that may act on an
expression:
• arithmetic
• logical
• relational
• trigonometric
• functional
• logarithmic
• string
• special function
Expressions
Expressions are simple or complex.
Simple expression:
12*EXP(A)/100,H(1) + 55,
Publication 1746-RM001A-US-P
Complex expression:
A stand alone variable [var] or constant [const] is also considered an expression.
Expressions are shown as:
[expr]
(SIN(A)*SIN(A)+COS(A)* COS(A)/2)
Operators
An operator performs a defined operation on variables or constants. Operators
require either one or two operands. Typical two operand operators include
ADD(+), SUBTRACT(-), MULTIPLY(*) and DIVIDE(/). We call operators that
require only one operand, single-operand operators. Typical single-operand
operators are SIN, COS, and ABS.
Expressions and Operators 3-3
Hierarchy of Operators
The hierarchy of operators is the order that the operations in an expression are
performed. You can write complex expressions using only a small number of
parentheses. To illustrate the hierarchy of operators, examine the following
equation:
4+3*2 = ?
In this equation, multiplication has precedence over addition. Therefore, multiply
(3*2) and then add 4.
4+3*2 = 10
When an expression is scanned from left to right, an operation is not performed
until an operator of lower or equal precedence is encountered. In the example, you
cannot perform addition until the multiplication operation is complete because
multiplication has a higher precedence. Use parentheses if you are in doubt about
the order of precedence or to enhance program readability. The precedence of
operators from highest to lowest in the module is:
1.
1. Operators that use parentheses ( )
1.1.
2.
2. Exponentiation (**)
2.2.
3.
3. Negation (-)
3.3.
Arithmetic Operators
4.
4. Multiplication (*) and division (/)
4.4.
5.
5. Addition (+) and subtraction (-)
5.5.
6.
6. Relational expressions (-, <>, >, >=, <, <-).
6.6.
7.
7. Logical AND (.AND.)
7.7.
8.
8. Logical OR (.OR.)
8.8.
9.
9. Logical XOR (.XOR.)
9.9.
The module contains a complete set of arithmetic operators that are divided into
two groups: dual-operand operators and single-operand operators.
The general form of all dual-operand instructions is:
(expr) OP (expr), where OP is one of the following arithmetic operators
Add ( + )
Use the Addition operator to add the first and the second expressions together.
ExampleResult
>PRINT 3+25
Publication 1746-RM001A-US-P
3-4 Expressions and Operators
Divide ( / )
Use the Division operator to divide the first expression by the second expression.
ExampleResult
>PRINT 100/520
Exponentiation ( **)
Use the Exponentiation operator to raise the first expression to the power of the
second expression. The maximum power to which you can raise a number is 255.
ExampleResult
>PRINT 2**38
Multiply ( * )
Use the Multiplication operator to multiply the first expression by the second
expression.
ExampleResult
>PRINT 3*39
Subtract ( - )
Use the Subtraction operator to subtract the second expression from the first
expression.
ExampleResult
>PRINT 9-63
Negation ( - )
Use the Negation operator to change an expression from positive to negative.
ExampleResult
>PRINT –(9+4)–13
Publication 1746-RM001A-US-P
Expressions and Operators 3-5
Overflow and Division by Zero
During the evaluation of an expression if an overflow, underflow, or division by
zero error occurs, the module generates error messages and reverts to Command
mode. Refer to the ONERR operation in chapter 8 for more information on how
to trap these errors.
The largest result allowed from any calculation is 0.99999999 E+127. If this
number is exceeded, the module generates the
and returns to Command mode.
The smallest result allowed from any calculation is 0.99999999 E-128. If this
number is exceeded, the module generates the
message and returns to Command mode.
If an attempt is made to divide any number by zero, the module generates the
ERROR: DIVIDE BY ZERO message and returns to Command mode.
>10 PRINT 9/0
>20 PRINT “PROGRAM SHOULD NOT GET HERE.”
ERROR: ARITH. OVERFLOW message
ERROR: ARITH. UNDERFLOW
READY
>RUN
ERROR: DIVIDE BY ZERO - IN LINE 10
10PRINT 9/0
-----------------X
READY
>
>10 PRINT 9.9E126*(2)
>
READY
>RUN
ERROR: ARITH. OVERFLOW - IN LINE 10
10PRINT 9.9E126*(2)
-------------------------X
READY
>
Publication 1746-RM001A-US-P
3-6 Expressions and Operators
Logical Operators
The module contains a complete set of logical operators that are divided into two
groups: dual-operand operators and single-operand operators.
The general form of all dual-operand instructions is:
(expr) OP (expr), where OP is one of the following logical operators.
These operators perform BIT-WISE logical operations on numbers between 0
(0000H) and 65535 (0FFFFH) inclusive. If the argument is outside this range,
then the module generates an
ERROR: BAD ARGUMENTmessage and returns to
Command mode. All decimal places are truncated, not rounded. Use the following
table for bit manipulations on 16-bit values.
Table 3.2 Bit Manipulations on 16-Bit Values
XYX .AND.YX .OR.YX .XOR.Y
00000
01011
10011
11110
.AND.
Use the logical .AND. operator to logically AND expressions together.
ExampleResult
>PRINT 3.AND.22
.OR.
Use the logical .OR. operator to logically OR expressions together.
ExampleResult
>PRINT 1.OR.45
.XOR.
Use the logical exclusive .XOR. operator to logically XOR expressions together.
ExampleResult
>PRINT 7.XOR.61
Publication 1746-RM001A-US-P
Expressions and Operators 3-7
Relational Operators
Relational expressions involve the operators =, < >, >, >=, <, and <=. In the module,
relational operations are typically used to test a condition. The module relational
operators return a result of 65535 (0FFFFH) if the relational expression is true, and
a result of 0 if the relation expression is false. The result returns to the argument
stack. Because of this, it is possible to display the result of a relational expression.
You can chain relational expressions with the logical operators .AND., .OR., and
.XOR.. This makes it possible to test a complex condition with ONE statement.
>10 IF (A>E).AND.(A>C).OR.(A>D)THEN...
Additionally, you can use the NOT([expr]) operator.
>10 IF NOT(A>E).AND.(A>C)THEN...
By chaining relational expressions with logical operators, you can test particular
conditions with one statement.
IMPORTANT
When using logical operators to link relational expressions, you
must be sure operations are performed in the proper sequence.
When in doubt, use parentheses.
Publication 1746-RM001A-US-P
3-8 Expressions and Operators
Trigonometric Operators
The module contains a complete set of trigonometric operators. These operators
are single-operand operators.
SIN([expr])
Use the SIN operator to return the sine of the argument. The argument is
expressed in radians. Calculations are carried out to 7 significant digits. The
argument must be between +
ExampleResult
>PRINT SIN(PI/4).7071067
>PRINT SIN(0)0
200000.
COS([expr])
Use the COS operator to return the cosine of the argument. The argument is
expressed in radians. Calculations are carried out to 7 significant digits. The
argument must be between +
ExampleResult
>PRINT COS(PI/4).7071067
>PRINT COS(0)1
200000.
TAN([expr])
Use the TAN operator to return the tangent of the argument. The argument is
expressed in radians. The argument must be between +
ExampleResult
>PRINT TAN(PI/4)1
>PRINT TAN(0)0
200000.
ATN([expr])
Use the ATN operator to return the arctangent of the argument. The result is in
radians. Calculations are carried out to 7 significant digits. The ATN operator
returns a result between –PI/2 (3.1415926/2) and PI/2.
ExampleResult
>PRINT ATN(PI)1.2626272
>PRINT ATN(1).78539804
Publication 1746-RM001A-US-P
Loading...
+ 250 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.