Declaring Arrays; B-3. Variable Data Type Declarations - Campbell CR300 Series Operator's Manual

Hide thumbs Also See for CR300 Series:
Table of Contents

Advertisement

CRBasic Example B-3. Variable Data Type Declarations
'This program example demonstrates various data type declarations. If not otherwise specified, data
'types default to floating point: As Float in Public or Dim declarations.
'Float Variable Examples
Public
Z
Public
X
As Float
'Long Variable Example
Public
CR300Time
As Long
Public
PosCounter
As Long
Public
PosNegCounter
As Long
'Boolean Variable Examples
Public
Switches(8)
As Boolean
Public
FLAGS(16)
As Boolean
'String Variable Example
Public
FirstName
As String
BeginProg
'Program logic goes here
EndProg
B.2.2 Declaring Arrays
* 16
'allows a string up to 16 characters long
Multiple variables of the same root name may be declared. The resulting series
of like-named variables is called an array. An array is created by placing a
suffix of (X) on the variable name. X number of variables are created that
differ in name only by the incrementing number in the suffix. For example, the
four statements
Public
TempC1
Public
TempC2
Public
TempC3
Public
TempC4
can simply be condensed to
Public TempC(4).
This statement creates in memory the four variables TempC(1), TempC(2),
TempC(3), and TempC(4).
A string array called StringVar, with five elements in the array and each
element with a length of 36 characters, is declared as
Public
StringVar(5)
This statement creates in memory the five variables StringVar(1),
StringVar(3), StringVar(4), and StringVar(5).
StringVar(2)
,
A variable array is useful in program operations that affect many variables in
the same way. CRBasic Example
temperatures (°C) to °F.
Appendix B. Introduction to CRBasic Programming
As String
* 36
B-4
shows compact code that converts four
B-5

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cr300-rf407Cr300-rf412Cr300-rf422

Table of Contents