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
patryn
Apprentice


Joined: 26 Sep 2001
Posts: 124

PostPosted: Sun Jan 16, 2005 11:31 am   

@rs.GetString returns a wrong length.
 
Utilizing Zmuds COM capability, i was able to create a custom RoomKind function. This simply goes into the map database and retrieves the RoomKind String name and then stores it in a local variable @RoomKind:

<snip>
RoomKind=@rs.GetString
<snip>

There is however a problem.
Lets say that after executing my custom function that the value of @RoomKind is now "Player_Room"
Lets also say that i have manually put the string "Player_Room" inside the variable @temp.

temp="Player_Room"

Ok. Now. The problem comes when i try to test for equivalency between the two strings. They are never equal, and after looking into it more deeply i found that they are not the same size.

%len(@temp) returns 11, while
%len(@RoomKind) returns 12

I've checked the @roomkind value for any spaces or other _deletable_ characters. I can't find any. There's no way that i can get the value in @RoomKind to equal that of @temp. (Unless i do it manually[1], but that defeats the purpose).

So, does anybody know how i can rectify this? It seems that @rs.GetString stores the string into @RoomKind somewhat differently then Zmud normally would.

Below is a more detailed example of what I'm talking about.


The Script im using to retrive RoomKind is this:
------------------------------------------------------------------------------
#VARIABLE MapConn %comcreate( "ADODB.Connection")
#CALL @MapConn.Open(%concat( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=", @LocalMapDatabase))
#VARIABLE rs @MapConn.Execute(%concat("SELECT k.name FROM KindTbl AS k, ObjectTbl AS o WHERE k.KindId = o.KindId AND o.ObjId =", %1,";"))
roomkind=@rs.GetString
#CALL @rs.Close
-----------------------------------------------------------------------------

#show @roomkind %len(@roomkind)
Returns:
Player_Room 12

temp="Player_Room"
#show @temp %len(@temp)
Returns:
Player_Room 11



Thanks in advance.


[1] When i say 'manually' i mean something like temp=@roomkind. Not simply going into the @roomkind variable and deleting any extra spaces. Because there are none.
_________________
That which does not kill us, makes us stronger.
Reply with quote
misterbalrog
Apprentice


Joined: 26 Oct 2004
Posts: 108

PostPosted: Sun Jan 16, 2005 2:18 pm   
 
Is it possible for the variable to contain an "invisible" new-line character? That would make a diff in it all.
Reply with quote
patryn
Apprentice


Joined: 26 Sep 2001
Posts: 124

PostPosted: Sun Jan 16, 2005 4:26 pm   
 
More then likely it does contain an 'invisible' new-line character.
But then, how do i get rid of it?

Like i said, it's not as easy as simply hitting delete or removing a character.
_________________
That which does not kill us, makes us stronger.
Reply with quote
misterbalrog
Apprentice


Joined: 26 Oct 2004
Posts: 108

PostPosted: Sun Jan 16, 2005 4:33 pm   
 
Tried using %replace with %char(13) ? or if that doesn't work, try with %crtonl and then replace it or something along the lines.

Or perhaps use an IF statement of %ends(@RoomType, %char(13)) and if true you just copy the entire string reduced by one character.

Or if you can change the trigger itself by adding $ to the pattern and thus removing the newline from the beginning.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Jan 16, 2005 4:53 pm   
 
Actually the most likely culprit is %char(0). This is because the C convention for strings is to use a null as a terminator. When this is returned zMud just puts the whole thing, null and all in. You can check this with:
#LOOP %len(@roomkind) {#ECHOP {%ascii(%copy(@roomkind,%i,1))-}};#ECHO {}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
patryn
Apprentice


Joined: 26 Sep 2001
Posts: 124

PostPosted: Mon Jan 17, 2005 11:55 am   
 
Thank you guys, it was the %char(13).

All fixed now, im a happy chappy.

Very Happy
_________________
That which does not kill us, makes us stronger.
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