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
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Tue Dec 07, 2004 3:34 pm   

%additem bug? failing to single quote first item
 
Ok I am using this bit of code

relevant secti:
Code:

#PRIO {
  #LOOPDB @item {
    #IF (!%null( %val)) {
      #NOOP
      query.keys=%additem( %char( 39)%key%char( 39), @query.keys)
      #IF (%isnumber( %val)) {
        #NOOP
        query.values=%additem( %val, @query.values)
        } {
        #NOOP
        query.values=%additem( %char( 39)%val%char( 39), @query.values)
        }
      }
    }
  }


And the first item in the both lists are NEVER single quoted the rest are quoted as they should be

%char(39)=' (the single quote)
strip quotes are on cause they just HAVE to be :P

I have tried this a bunch of differant ways and can't get any of them to work. So if anyone has any Ideas on how to make this work PLEASE lemme know
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Tue Dec 07, 2004 6:38 pm   
 
The problem is that when there is only 1 item in the list, and you add another with %additem, it strips the quotes. I have a workaround to counter this, but there probably is another way. What it does, is after it adds another item to the variable, thus making it a list, it puts the quotes back into the first item on the list, given it is a number.

#PRIO {
#LOOPDB @item {
#IF (!%null( %val)) {
#NOOP
query.keys=%additem( %char( 39)%key%char (39), @query.keys)
#IF (%isnumber( %val)) {
#NOOP
query.values=%additem( %val, @query.values)
} {
#NOOP
query.values=%additem( %char( 39)%val%char( 39), @query.values)
}
}
}
#if ((%numitems(@query.keys)>1) AND (!%isnumber(%item(@query.keys, 1)))) {query.keys=%replaceitem(%char( 39)%item(@query.keys,1)%char( 39), 1, @query.keys)}
}
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Wed Dec 08, 2004 1:29 pm   
 
Hmmm I'll have to try that one :P

Shortly after posting I just decided to use ^ in place of the single quote and just convert it to ' using a %replace
_________________
Zmud Support Library
Zmud Knowledge Base
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