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


Joined: 18 Jan 2001
Posts: 116
Location: USA

PostPosted: Sat Jun 07, 2003 3:56 pm   

different results for same alias
 
I have a script attached for a test example of a problem I'm having... it's where I'm using an alias to generate a speed menu. If I right click on the alias in the settings editor and select EXECUTE then the speed menu is created correctly. However, if I run the alias from the command line (or it's fired by a trigger) then the value of the menu item is wrong. It comes down to the expansion of %%i in a nested forall loop. If executed from the settings editor it expands as expected, but from the command line it expands to just %i. I'm sure it's something I'm doing wrong.. but could someone tell me how to get around this problem?

Thanks in advance.

Eupher

#CLASS {testing}

#ALIAS generate_test_menu {
#DELCLASS testing|testing_menu
#CLASS {testing|testing_menu} {menu}
#FORALL @recipe_names {
#MENU {%i} {} "" {%{i}_menu}
#CLASS {testing|testing_menu|%{i}_menu} {menu}
#MENU {Edit} {
#VARIABLE ingredients_pick_list "" {} {testing}
#FORALL @ingredients {#IF (%ismember( %%i, %db( @recipes, %i))) {#ADDITEM ingredients_pick_list %concat( "*", %%i)} {#ADDITEM ingredients_pick_list {%%i}}}
#ADDKEY ingredients_pick_list {%i} %pick( "p:Select the ingredients to make %i", {@ingredients_pick_list})
generate_test_menu
} ""
#MENU {Delete} {#YESNO "Delete the %i recipe?" {
#DELKEY recipes {%i}
generate_test_menu
}}
#CLASS {testing|testing_menu} {menu}
}
#CLASS 0
}
#VARIABLE recipes {meatloafchocolate cakepasta salad}
#VARIABLE ingredients {meat|onion|noodles|tomatoes|mayo|flour|egg|milk|oil}
#VARIABLE recipe_names {meatloaf|chocolate cake|pasta salad}
#VARIABLE ingredients_pick_list {meat|onion|noodles|tomatoes|mayo|flour|egg|milk|oilmeatloaf} {}
#MENU {Testing Menu} {} "" {testing_menu}
#CLASS 0
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Jun 07, 2003 6:22 pm   
 
This appears to be a bug in how the delayed expansion is preformed. You can get around this by putting "%i" into a variable and then replacing the "%%i" with a reference to that variable.
Reply with quote
eupher
Apprentice


Joined: 18 Jan 2001
Posts: 116
Location: USA

PostPosted: Sat Jun 07, 2003 7:57 pm   
 
Thanks for the tip, it worked great.

Hehe.. you wouldn't believe how long I banged my head against the wall trying to figure out why the alias was working sometimes and not others :)

Thanks again.

Eupher
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