Campbell-scientific CR9000X Measurement and Control System Manual de usuario Pagina 179

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 442
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 178
Section 5. Program Declarations
encountering the EndFunction command, the Function will
return NAN.
Function Example
'In this example, Function Secant calculates the secant of an angle. Note
'that the Angle variable's value, in the main Scan, would not be modified
'by the Function call.
AngleDegrees
Public Angle, Var, Secant, X, Y
Function Secant(F_Angle as Float) as Float
Dim F_Angle
Secant = 1/Cos(F_Angle)
EndFunction
BeginProg
X=1 : Y = 1 ' Initialise X, and Y so the angle is 45 degrees
Scan(1,Sec,3,0)
Angle = ATN2(X,Y)
Var = Secant(Angle)
NextScan
EndProg
PUBLIC
Like the Dim statement, the Public statement is used to declare variables and
variable arrays, and allocate storage space for these variables.
The difference is
that variables declared using the Public statement can be monitored at the
measurement scan rate using the various CSI software packages through the Public
Table.
Syntax
Public VarName (size subscripts) Or
Public VarName (size subscripts) As Type Or
Public VarName (size subscripts) As Type = {3,6,2, . , , ,5}[initialise values]
Remarks
In CRBasic, ALL variables MUST be declared. Variables are typically declared
at the beginning of the program and the default value is initialized to a value of 0
unless otherwise declared.
A Public statement can be used for each variable declared, or multiple
variables can be defined on one line with one Public statement. If the latter is
done, the variables should be separated by a comma (e.g., "Public Scratch1,
Scratch2, Test" declares three variables). A variable array is created by
following the variable name with the number of elements enclosed in
parenthesis (e.g., Public Temp(3) creates Temp(1), Temp(2), and Temp(3)).
Two- and three-dimensional arrays can also be defined. A declaration of Dim
Temp(3,3,3) would create 29 variables: Temp(1,1,1), Temp(1,1,2),
Temp(1,1,3), Temp(1,2,1), Temp(1,2,2) … Temp(3,3,3). In the program, the
array can be referenced using the multi-dimensional form, or using an index
into the array.
5-9
Vista de pagina 178
1 2 ... 174 175 176 177 178 179 180 181 182 183 184 ... 441 442

Comentarios a estos manuales

Sin comentarios