![background image](http://html1.mh-extra.com/html/campbell/cr300-series/cr300-series_operators-manual_3055705075.webp)
Appendix B. Introduction to CRBasic Programming
B-5
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
* 16
'allows a string up to 16 characters long
BeginProg
'Program logic goes here
EndProg
B.2.2 Declaring Arrays
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)
As String
* 36
This statement creates in memory the five variables
StringVar(1)
,
StringVar(2)
,
StringVar(3)
,
StringVar(4)
, and
StringVar(5)
.
A variable array is useful in program operations that affect many variables in
the same way. CRBasic Example
shows compact code that converts four
temperatures (°C) to °F.
Содержание CR300 series
Страница 2: ......
Страница 6: ......
Страница 68: ...CR300 Series Datalogger 58...
Страница 70: ......
Страница 85: ......