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.

message Warning: Variable period out of bounds.


FB5802 Mar 4, 2020 10:34 AM

Hello,
I have this message when this program is running but not when is compiling.
I don't understand why, because the size between arrays and variables are the same.
Could you explain me ?

Thank you very much

best regards

Public PTemp, Batt_volt
Public i,k
Public flag1 As Boolean
Public flag2 As Boolean

'---------------------------------------

Public rTime(9)
Alias rTime(1) = Annee
Alias rTime(2) = Mois
Alias rTime(3) = Jour
Alias rTime(4) = Heure
Alias rTime(5) = Minute
Alias rTime(6) = Seconde
Alias rTime(7) = uSeconde
Alias rTime (8) = Jr_sem
Alias rTime (9) = Jr_an
'----------------------------------------

'------------------
Public period(17)
Alias period(1)= a31_15
Alias period(2)= a31_15_2
Alias period(3)= a31_15_3
Alias period(4)= a31_45
Alias period(5)= a31_45_2
Alias period(6)= a31_75
Alias period(7)= a31_75_2
Alias period(8)= a31_105
Alias period(9)= a31_105_2
Alias period(10)= a31_135
Alias period(11)= a31_135_2
Alias period(12)= a31_165
Alias period(13)= a31_165_2
Alias period(14)= a31_195
Alias period(15)= a31_195_2
Alias period(16)= a31_235
Alias period(17)= a31_235_2

'------------------
Public temp(10)
Alias temp(1)= a31_t15
Alias temp(2)= a31_t15_2
Alias temp(3)= a31_t15_3
Alias temp(4)= a31_t45
Alias temp(5)= a31_t75
Alias temp(6)= a31_t105
Alias temp(7)= a31_t135
Alias temp(8)= a31_t165
Alias temp(9)= a31_t195
Alias temp(10)= a31_t235
'Declare Private Variables
'Example:
'Dim Counter

'Define Data Tables.
DataTable (tdr_a31,1,1000)
Sample(17,period(),fp2)
EndTable

DataTable (temp_a31,1,1000)
Sample(10,temp(),fp2)
EndTable

Sub tdr
RealTime (rTime)
'Scan (2,Sec,1,1)
MuxSelect (C2,C1,20,1,1)
For i = 1 To 17
CS616 (period(i),1,1,C3,1,1,0)
i = i+1
CS616 (period(i),1,2,C3,1,1,0)
i = i+1
CS616 (period(i),1,3,C3,1,1,0)
PulsePort (C2,10000)
Next
PortSet (C1,0)
PortSet (C2,0)

PortSet (C3,0)
flag1=false
EndSub

Sub T107
MuxSelect (C2,C1,20,7,1)
For k = 1 To 10
PortSet (C3,0)
Therm107 (temp(k),1,1,Vx1,2000,_50Hz,1,0)
k=k+1
Therm107 (temp(k),1,2,Vx1,2000,_50Hz,1,0)
k=k+1
Therm107 (temp(k),1,3,Vx1,2000,_50Hz,1,0)

PulsePort (C2,10000)

Next
PortSet (C1,0)
EndSub

BeginProg
Scan (30,Min,2,0)
RealTime (rTime)
PanelTemp (PTemp,60)
Battery (Batt_volt)

'mesure des thetaprobes
'******************************************
MuxSelect (C2,C1,20,1,1)
For i = 1 To 17
CS616 (period(i),1,1,C3,1,1,0)
i = i+1
CS616 (period(i),1,2,C3,1,1,0)
i = i+1
CS616 (period(i),1,3,C3,1,1,0)
PulsePort (C2,10000)
Next
PortSet (C1,0)

PortSet (C2,0)

PortSet (C3,0)

'*******************************************
Delay (0,500,mSec)

'mesure des 107
'+++++++++++++++++++++++++++++++++++++++++++
MuxSelect (C2,C1,20,7,1)
For k = 1 To 10

PortSet (C3,0)
Therm107 (temp(k),1,1,Vx1,2000,_50Hz,1,0)
k=k+1
Therm107 (temp(k),1,2,Vx1,2000,_50Hz,1,0)
k=k+1
Therm107 (temp(k),1,3,Vx1,2000,_50Hz,1,0)

PulsePort (C2,10000)

Next
PortSet (C1,0)
'***************************************************

CallTable tdr_a31
CallTable temp_a31

If flag1=true Then
Call tdr
flag1=false
EndIf

If flag2=true Then
Call T107
flag2=false
EndIf


NextScan
EndProg


GaryTRoberts Mar 4, 2020 03:34 PM

Just doing a manual count of the For i = 1 To 17 Next loop, it looks like your counter i gets to 18 before exiting the loop. You only have period declared to array size of 17.

Each time the program goes through the for loop i get incremented by +1 three times. 6 times through the for loop put i at 18. i is only evaluated if it is great then 17 at the beginning of the For loop.

I would do something like this:

For i = 1 To 17
CS616 (period(i),1,1,C3,1,1,0)
i = i+1

If i > 17 ExitFor
CS616 (period(i),1,2,C3,1,1,0)
i = i+1

If i > 17 ExitFor
CS616 (period(i),1,3,C3,1,1,0)
PulsePort (C2,10000)
Next

Or something along those lines.

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