Crbasic example 10. flag declaration and use – Campbell Scientific CR1000 Measurement and Control System User Manual

Page 121

Advertising
background image

Section 7. Installation

121

 

DataTable

(TableName,True,-1)

'FP2 Data Storage Example

Sample

(1,Z,FP2)

'IEEE4 / Float Data Storage Example

Sample

(1,X,IEEE4)

'UINT2 Data Storage Example

Sample

(1,PosCounter,UINT2)

'LONG Data Storage Example

Sample

(1,PosNegCounter,Long)

'STRING Data Storage Example

Sample

(1,FirstName,String)

'BOOLEAN Data Storage Example

Sample

(8,Switches(),Boolean)

'BOOL8 Data Storage Example

Sample

(2,FLAGS(),Bool8)

'NSEC Data Storage Example

Sample

(1,CR1000Time,Nsec)

EndTable

 

Flags

Flags are a useful program-control tool. While any variable of any data type can
be used as a flag, using Boolean variables, especially variables named "Flag",
works best. CRBasic example Flag Declaration and Use

(p. 121)

shows an example

using flags to change the word in string variables.

CRBasic Example 10. Flag Declaration and Use 

Public

Flag(2)

As Boolean

Public

FlagReport(2)

As String

BeginProg

Scan

(1,Sec,0,0)

If

Flag(1) = True

Then

FlagReport(1) = "High"

Else

FlagReport(1) = "Low"

EndIf

If

Flag(2) = True

Then

FlagReport(2) = "High"

Else

FlagReport(2) = "Low"

EndIf

NextScan

EndProg

 

Advertising