Hi All
I am somewhat new to crbasic and have a couple of questions:
1) Is there an intrinsic function in the language which returns the maximum of two values, for instance A = MAX(B,C) where A, B and C are all single values of the same type. I know there is max functions in tables but I need to do a max between two calculated values which are not in any datatables.
2) I know that I can initialize elements of an array as follows:
a(3)
a(1) = 1.0
a(2) = 2.0
a(3) = 3.0 ect
I would like to be able to do a more classic initialization I am used to in other programming languages such as:
a(3) = ( 1.0, 2.0, 3.0 ) , this form is more compact.
Thanks
Marco
Answers:
1) Check out the MaxSpa instruction, but the data does have to be in an array. There also equivalent Min and other statistical instructions.
2)You can delare values similar to the way you want when you declare the variable - check out the help on the Public and Dim instructions. We also support the old Data and Read instructions for loading arrays with initial values.
You can use this:
A = IIF(B>C,B,C)
----
From CRBasic Help:
IIF
The IIF function is used to evaluate an expression and return one of two values based on that evaluation.
Syntax
IIF( Expression, TrueValue, FalseValue )