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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
robert
Wanderer


Joined: 25 Feb 2004
Posts: 98

PostPosted: Tue Oct 04, 2011 10:00 pm   

Convert string list to Alias
 
Hey All,

I have a very long string list that is just a set of commands I want to execute. I would like a method to create an alias from it as I think it would be faster than doing a #FORALL @stringlist {#EXECUTE %i}. The list is around 7000 lines right now and looping through it actually takes some significant time. While typing this up, I thought about using #SENDRAW instead of #EXECUTE as that is likely faster also. Any other ideas?

Thanks!
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Tue Oct 04, 2011 10:39 pm   
 
You can use the #alias command to create aliases in a script.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Oct 04, 2011 10:44 pm   
 
1)create new alias
2)on command line, type #PRINT %expandlist(@stringlist,%cr)
3)copy-paste #PRINT result to alias

Beyond that, you might want to look for patterns in your list so that you can create a looping script (trigger1 fires, sends command that sends output for trigger2, which sends command that sends output for triggerN, etc) without having to use #FORALL, #LOOP, #LOOPDB, #WHILE, or #UNTIL.

Also, #SENDRAW only sends literal text. It doesn't expand variable or function references, so #SENDRAW @stringlist.%i will send the literal string of "@stringlist.%i" instead of the ith member of the variable stringlist.
_________________
EDIT: I didn't like my old signature
Reply with quote
robert
Wanderer


Joined: 25 Feb 2004
Posts: 98

PostPosted: Wed Oct 05, 2011 1:27 pm   
 
I did the copy paste method. :)

#EXECUTE loop took 87.740 seconds

Alias took 63.667.

So alias it significantly faster than #EXEC LOOP. Anyone got a faster method? :)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Oct 05, 2011 3:28 pm   
 
An alias would probably be the fastest method, since it has the raw commands and is compiled. The only way to make it faster would be to optimize the commands themselves, and that will depend on exactly what your list of commands is.
Reply with quote
robert
Wanderer


Joined: 25 Feb 2004
Posts: 98

PostPosted: Wed Oct 05, 2011 4:23 pm   
 
It is a mix of directions, and commands to send to the mud in each room in the alias at least now. In the string list it is a mix of paths and commands to send to the mud. I am thinking I could try to do a similar print and expand the paths but with a #SENDRAW before it, then copy that into an alias? Perhaps that would be faster?

Something like
#FORALL @stringlist {
$ExpandedPath = %pathexpand(%i)
#FORALL $ExpandedPath {#PRINT "#SENDRAW" %expandlist(%i,%cr)}
} and then copy into an alias?

Thanks all for you help. :)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Oct 05, 2011 5:30 pm   
 
If all the commands are literal commands to be sent straight to the mud without parsing, then it might indeed be a bit faster to put #SENDRAW before every command. The paths currently need to be parsed, but something like your last bit of code should fix that.

The one issue I wonder about is: you are basically creating a script that spams something like 10,000 commands to the mud within one minute. That's almost the same scale as a denial-of-service attack. I would worry about how the mud administrators would feel about it.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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