Dynamic Array puzzle 
Author Message
 Dynamic Array puzzle

I'm putting items into a dynamic array and then iterating through the
array to post records to a Paradox database.

I'm puzzled as to why the records go into the database in the reverse
order to that which they were added to the array. In other words if
records go into the array in the sequence A1, A2, A3, when I write them
out they appear in the database as record number 1 = A3, record number
2 = A2 and record number 3 = A1.

The database is (deliberately) unindexed and I am definitely not
accessing the array in reverse sequence during the iteration - I use an
array index starting at zero and incrementing after each post to the
database.

Using delphi 4 Build 5.37

TIA

 ++ *Paul*
 ++ from Cheltenham, England  
 ++ Tue, 03 Nov 1998 20:00 GMT  
 ++ WinNT4 build 1381 + SP3
 ++ http://freespace.{*filter*}.net/paul.richards/



Sat, 21 Apr 2001 03:00:00 GMT  
 Dynamic Array puzzle
It's pretty simple explanation.
If your using
  Ttable.insert
        [your data].[field1]
        [ your data]    .[field2]   ect.
 ttable post

then start again.

After you post the new record is your current record. Insert inserts a
new record in front of current record. Helps in preventing you from
posting a record after the eof marker.

On Tue, 03 Nov 1998 20:18:07 GMT, Paul Richards

Quote:

>I'm putting items into a dynamic array and then iterating through the
>array to post records to a Paradox database.

>I'm puzzled as to why the records go into the database in the reverse
>order to that which they were added to the array. In other words if
>records go into the array in the sequence A1, A2, A3, when I write them
>out they appear in the database as record number 1 = A3, record number
>2 = A2 and record number 3 = A1.

>The database is (deliberately) unindexed and I am definitely not
>accessing the array in reverse sequence during the iteration - I use an
>array index starting at zero and incrementing after each post to the
>database.

>Using delphi 4 Build 5.37

>TIA

> ++ *Paul*
> ++ from Cheltenham, England  
> ++ Tue, 03 Nov 1998 20:00 GMT  
> ++ WinNT4 build 1381 + SP3
> ++ http://freespace.{*filter*}.net/paul.richards/



Mon, 23 Apr 2001 03:00:00 GMT  
 Dynamic Array puzzle
On Tue, 03 Nov 1998 20:18:07 GMT, Paul Richards

Quote:

>I'm putting items into a dynamic array and then iterating through the
>array to post records to a Paradox database.

>I'm puzzled as to why the records go into the database in the reverse
>order to that which they were added to the array. In other words if
>records go into the array in the sequence A1, A2, A3, when I write them
>out they appear in the database as record number 1 = A3, record number
>2 = A2 and record number 3 = A1.

>The database is (deliberately) unindexed and I am definitely not
>accessing the array in reverse sequence during the iteration - I use an
>array index starting at zero and incrementing after each post to the
>database.

Apart the valid advice already given to you by others, I wish to add
the following:

if you use a <for> cycle which does nothing strange, like:

for i:=0 to xxx.Count-1 do begin
   Append;
   FieldByName('Field1').As...:=...;
   FieldByName('Field2').As...:=...;
   Post;
End;

then you should know that in certain circumstances the optimizer could
decide to execute an equivalent "For ... downto ..." cycle instead of
the one you specified.  This happens if the optimizer thinks that the
result should be identical, because it is more efficient.

I don't know if this applies to your case, though.

Regards,

--
Marco Rocci
MicroEra srl
Turin, Italy



Fri, 25 May 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. dynamic array

2. Dynamic array in database

3. How to store dynamic array to memofield?

4. Dynamic Type array

5. How to declare dynamic array in fpc ??

6. dynamic arrays

7. Memory access; relative position (dynamic array)

8. Heap error while allocating dynamic array in protected.

9. How do you do a dynamic array in oascal

10. Dynamic (list-like) arrays in Delphi

11. Dynamic arrays?????

12. Question: Dynamic arrays in Turbo Pascal

 

 
Powered by phpBB® Forum Software