About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 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
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Wed May 24, 2006 2:09 am   

#FORALL
 
Is there a way to end a loop early? What I want to do is use #FORALL to loop through a record to see if an entry is there already. If it isn't, it will add the value to the record. But if it is, there is no point to continuing the loop. I know I can just let it go over the whole record and set a flag to be true if it is found, but I would prefer to not waste memory.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4752
Location: Pensacola, FL, USA

PostPosted: Wed May 24, 2006 2:33 am   
 
#ABORT
_________________
Discord: Shalimarwildcat
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed May 24, 2006 3:49 am   
 
You are wanting to loop through the keys of a datarecord variable to see if the key exists, or am I not understanding correctly? This could be better accomplished with an #IF and an %iskey(). %iskey() works just like %ismember() does for stringlists.
_________________
EDIT: I didn't like my old signature
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Wed May 24, 2006 11:42 am   
 
It's more of looping through the values a key has than the keys themselves. In more detail, I'm going to try to record the creatures in an area, with the area being the key, so basically an #addkey area creature1, #addkey area creature2, etc, etc. But I don't want repetition for the current area, so I am going to loop through the values already in the key first and if it exists in the key already, it won't add it.

I know I can probably use a database for this, but I've never had much success with database usage and it is only a temporary thing.
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Wed May 24, 2006 1:48 pm   
 
#ADDKEY
... Key must be unique. Any existing value for the given key is replaced with the new value ...

So shouldn't have to loop through and check, since you can't create duplicates anyway.
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
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