Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

basic crbasic


ma Sep 4, 2013 07:23 PM

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


aps Sep 5, 2013 07:30 AM

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.


GTProdMgr Sep 5, 2013 04:41 PM

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 )

Log in or register to post/reply in the forum.