Re: array with same value all the time?
- From: "Tom de Neef" <tdeneef@xxxxxxxx>
- Date: Mon, 27 Mar 2006 21:07:17 +0200
"Sonnich" <sonnich.jensen@xxxxxxxxxxxxxx> schreef in bericht
news:1143474738.112955.64510@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi!
I have a project where I collect data into this:
TDataRec = record
Name: string[81];
RecordTime: TDateTime;
Value: double;
end;
I have an array ot that; where I add data when I get it (it happens in
a thread) - there is a TCristicalSection to avoid multiple instances
using it.
There is a procedure in the thread, which adds data.
The execute part looks at data, when there is enough, it goes in,
processes data, and delete them (that means - moving them, and setting
the array that much shorter using SetLenght) - usually it is cleared to
0 size.
{ delete used data }
i := iUsedData;
while i < Length(aData) do
begin
aData[i-iUsedData] := aData[i];
Inc(i);
end;
SetLength(aData, Length(aData) - iUsedData);
My problem is that sometimes for some reason, the Value is the same for
all records - that is possible, that it might happen once in a million
years, but not once a day as I get it. The name is the same, but the
timestamp is chaning correctly. It is just the recieved value, which
repeats itself.
That behaviour can not be the result of the code you publish above, which
just shifts data. I would say that it happens at the point where the data is
collected. You say consecutive records have Name and Value identical but the
timestamp changes. You do not show code of the data collection part.
Is there a particular reason to use a dynamic array rather than a Tlist
(with objects instead of records)? Adding and deleting would be more
elegant.
Tom
.
- Follow-Ups:
- Re: array with same value all the time?
- From: Sonnich
- Re: array with same value all the time?
- From: Bruce Roberts
- Re: array with same value all the time?
- References:
- array with same value all the time?
- From: Sonnich
- array with same value all the time?
- Prev by Date: Re: how to install to multiple clients over a network?
- Next by Date: Re: array with same value all the time?
- Previous by thread: array with same value all the time?
- Next by thread: Re: array with same value all the time?
- Index(es):
Relevant Pages
|