Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Erasmus
Wanderer


Joined: 04 Aug 2004
Posts: 82
Location: Philadelphia

PostPosted: 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
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: 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 :)
Reply with quote
Erasmus
Wanderer


Joined: 04 Aug 2004
Posts: 82
Location: Philadelphia

PostPosted: Sat Oct 20, 2007 9:29 pm   
 
Quote:
It is easy enough to test this theory by just putting three or four echo messages with move next calls in between.


Were you thinknig of something like this?
Code:
#LOOP 20 {#ECHO @MapConnection.Fields("ObjID").Value;#CALL @MapConnection.MoveNext;#ECHO Test 1;#CALL @MapConnection.MoveNext;#ECHO Test 2;#CALL @MapConnection.MoveNext;#ECHO Test 3#CALL @MapConnection.MoveNext}


That gave the output of:
Code:
1
Test 1
Test 2
Test 3

20 times

I guess I'm confused why this is happening. In posts like:

http://forums.zuggsoft.com/forums/viewtopic.php?t=24106
http://forums.zuggsoft.com/forums/viewtopic.php?t=22806
http://forums.zuggsoft.com/forums/viewtopic.php?t=20089

People are using WHILE loops to test and move to each record, and no one has reported the same problem.
_________________
Erasmus
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: 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 :)
Reply with quote
Erasmus
Wanderer


Joined: 04 Aug 2004
Posts: 82
Location: Philadelphia

PostPosted: 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
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: 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 :)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net