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.

Alias definition


heiko Nov 30, 2012 11:23 AM

Hi,

what does the field or array definition realy mean?

I have the followin code


'===BEGIN definition DTS FTS turbidity sensor =========

Const SensorNumDTS = 11 ' number of DTS Sensors

Dim nDTS, i, j ' counter for DTS Sensor within a loop
Dim addressDTS As String
Dim Adresse(SensorNumDTS) As String

Public rTime(9) 'declare as public and dimension rTime to 9
Public Minute
Public nrDTS
Dim n2DTS

Public DTS_Val(SensorNumDTS,8)

Alias DTS_Val(SensorNumDTS,1)=MeanTurb(SensorNumDTS)
Alias DTS_Val(SensorNumDTS,2)=VarTurb(SensorNumDTS)
Alias DTS_Val(SensorNumDTS,3)=MedianTurb(SensorNumDTS)
Alias DTS_Val(SensorNumDTS,4)=BESTurb(SensorNumDTS)
Alias DTS_Val(SensorNumDTS,5)=MinTurb(SensorNumDTS)
Alias DTS_Val(SensorNumDTS,6)=MaxTurb(SensorNumDTS)
Alias DTS_Val(SensorNumDTS,7)=Temp_DTS12(SensorNumDTS)
Alias DTS_Val(SensorNumDTS,8)=WipeStatus(SensorNumDTS)

Public ArrayLenDTS_Val,ArrayLenMeanTurb,ArrayLenVarTurb, ArrayLenBESTurb

DataTable(DTS_B4_tst,True,-1)
DataInterval(0,2,Min,10)
Sample(SensorNumDTS,Adresse(),String)
Sample(SensorNumDTS,MeanTurb(),IEEE4)
Sample(SensorNumDTS,VarTurb(),IEEE4)
Sample(SensorNumDTS,MedianTurb(),IEEE4)
Sample(SensorNumDTS,BESTurb(),IEEE4)
Sample(SensorNumDTS,MinTurb(),IEEE4)
Sample(SensorNumDTS,MaxTurb(),IEEE4)
Sample(SensorNumDTS,Temp_DTS12(),IEEE4)
Sample(SensorNumDTS,WipeStatus(),IEEE4)

EndTable

'=====END definition DTS FTS turbidity sensor===========


'Main Program
BeginProg
Scan(1,Min,0,0)


'=====BEGIN SDI12-Turbidity Measurements===============
RealTime(rTime) ' get array of time
Minute = rTime(5) ' define Minutes as nDTS
n2DTS = Floor(Minute/SensorNumDTS)
nDTS = (Minute + 1) - n2DTS*SensorNumDTS
nrDTS = nDTS

addressDTS=CHR(nrDTS+64)

SDI12Recorder(DTS_Val(nrDTS,1),7,addressDTS,"M2!",1,0)

Adresse(nrDTS) = addressDTS
VarTurb(nrDTS) = DTS_Val(nrDTS,2)
MedianTurb(nrDTS) = DTS_Val(nrDTS,3)
BESTurb(nrDTS) = DTS_Val(nrDTS,4)
MinTurb(nrDTS) = DTS_Val(nrDTS,5)
MaxTurb(nrDTS) = DTS_Val(nrDTS,6)
Temp_DTS12(nrDTS) = DTS_Val(nrDTS,7)
WipeStatus(nrDTS) = DTS_Val(nrDTS,8)
MeanTurb(nrDTS) = DTS_Val(nrDTS,1)

ArrayLenDTS_Val = ArrayLength(DTS_Val)
ArrayLenMeanTurb = ArrayLength(MeanTurb)
ArrayLenVarTurb = ArrayLength(VarTurb)
ArrayLenBESTurb = ArrayLength(BESTurb)


'========BEGIN Call Table FTS================
CallTable(DTS_B4_tst)

NextScan

EndProg


=============================

ArrayLenDTS_Val
--> the value is 88 - that´s right because I have 11 Sensors and each gives 8 values!
ArrayLenMeanTurb
--> the value is 88 - that´s wrong!!!! Because is index is just running until 11 (nrDTS)

That means the program is doning some stupid things that I don´t real understand!

Any suggestions??
Thanks
Heiko

* Last updated by: heiko on 11/30/2012 @ 4:31 AM *


smh Nov 30, 2012 04:37 PM

I think your code returns 88 because the ArrayLength function

".. returns an integer that represents the total number of elements in all the dimensions of an array." (taken from CRBasic help.

The Alias that you have defined (MeanTurb) is only giving a name to part of another array DTS_Val.

In fact I'm not sure that you have defined what you intended - you have Aliases for the single elements (11,1), (11,2), (11,3) etc whereas I think you meant to define all elements (x,1) to be in the array known as MeanTurb()

Not sure how you would do this, although I'm by no means an old hand at CRBasic myself ! There may be others out there more qualified to answer you more fully.

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