|
Erasmus Wanderer
Joined: 04 Aug 2004 Posts: 82 Location: Philadelphia
|
Posted: Sat Oct 20, 2007 5:53 pm
ADO Recordset Scripting Issues |
In an effort to improve the speed of finding a room on my map (I currently use a alias that calls %mapfilter and is so slow its like watching paint dry). I've been playing around with the ADO connection features in zMud (also checkout out mapquery, but in my tests ADO is a lot faster). I've been having trouble looping through the records using either #LOOP or #WHILE, and I can't figure out why.
Code: |
#VARIABLE MapConnection %comcreate( "ADODB.Recordset")
#CALL %comset(MapConnection,"CursorType", 3)
#CALL @MapConnection.Open("SELECT * FROM ObjectTbl INNER JOIN ZoneTbl ON ObjectTbl.ZoneID = ZoneTbl.ZoneId ORDER BY ObjID", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Aardwolf/Aardwolf.mdb")
#LOOP 20 {#ECHO @MapConnection.Fields("ObjID").Value;#CALL @MapConnection.MoveNext} |
I would expect to the #ECHO to display the numbers of the first 20 rooms in the table, in this case 1 - 20. Instead it displays "1" 20 times. Running the Loop again will display "2" 20 times, etc. It seems like it isn't moving to the next record fast enough for the loop. Is this normal? Is there a way around it? |
|
_________________ Erasmus |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Sat Oct 20, 2007 8:20 pm Re: ADO Recordset Scripting Issues |
Erasmus wrote: |
It seems like it isn't moving to the next record fast enough for the loop. Is this normal? Is there a way around it? |
Either that or it's not moving to the next record until the loop process is finished. This is more likely to be the case. Windows processing messages are more than likely held off while the loop is in progress. It is easy enough to test this theory by just putting three or four echo messages with move next calls in between.
If that works then I'd say that it is normal behaviour and I'm not sure there is any way around it. |
|
_________________ Taz :) |
|
|
|
Erasmus Wanderer
Joined: 04 Aug 2004 Posts: 82 Location: Philadelphia
|
|
_________________ Erasmus |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Sun Oct 21, 2007 10:42 pm |
I meant not using a loop at all. I meant the following.
#ECHO @MapConnection.Fields("ObjID").Value
#CALL @MapConnection.MoveNext
#ECHO @MapConnection.Fields("ObjID").Value
#CALL @MapConnection.MoveNext
#ECHO @MapConnection.Fields("ObjID").Value
#CALL @MapConnection.MoveNext
#ECHO @MapConnection.Fields("ObjID").Value
#CALL @MapConnection.MoveNext |
|
_________________ Taz :) |
|
|
|
Erasmus Wanderer
Joined: 04 Aug 2004 Posts: 82 Location: Philadelphia
|
Posted: Mon Oct 22, 2007 1:30 am |
Oh, yes that works as expected. The problem only seems to manifest itself in loops. For some reason the MoveNext method isn't executing right.
I tested a little bit today.
Code: |
#LOOP 5 {#CALL @MapConnection.MoveNext} |
This will advance the record once, not 5 times as you'd expect.
Even stranger (I think),
Code: |
#CALL @MapConnection.MoveFirst
#LOOP 3 {#ECHO @MapConnection.Fields("ObjID").Value;#CALL @MapConnection.MoveNext;#CALL @MapConnection.MoveNext;#CALL @MapConnection.MoveNext;#CALL @MapConnection.MoveNext;#ECHO @MapConnection.Fields("ObjID").Value} |
returns:
1
5
1
5
1
5
where my ObjID's are 1,2,3,4,5,6,7.....etc.
Is this resetting to record one after each loop, or.....I don't know? |
|
_________________ Erasmus |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Mon Oct 22, 2007 7:27 pm |
The only difference I saw on those other posts was the MoveFirst command, not sure if that is what is causing the problems.
|
|
_________________ Taz :) |
|
|
|
|
|