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


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Sun Oct 03, 2004 4:36 pm   

#menu and variable caption
 
Hello,

Does anyone know why this doesn't work?
test="hello"
#menu @test {#echo test} "menu"

What happens is that @test is not expanded. I have even tried using the [] syntax without much success. That is this doesn't work either:
#menu {[@test]} {#echo test} "menu"

Thanks for helping me solve this :-).
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Sun Oct 03, 2004 4:38 pm   
 
Ok I found a method to solve this myself :-).

To solve it I found that this works:
#exec %concat( "#menu {", %roomname( ), "} {#echo test} ", "menu")

Probably because #exec fully expands its arguments unlike #menu. Still this seems to be a pretty odd thing with zScript. Does anyone know if this is a good way to solve this problem or is there any better method?


Last edited by Rorso on Sun Oct 03, 2004 4:42 pm; edited 1 time in total
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Oct 03, 2004 4:42 pm   
 
*Destroys his last post*

Your right :P


Last edited by nexela on Sun Oct 03, 2004 4:49 pm; edited 1 time in total
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Sun Oct 03, 2004 4:47 pm   
 
I updated my own fix as it didn't work well with the syntax checker. It works for you? :-). I might need to explain the issue a bit better as it is a bit odd.

When #menu @test {#echo test} "menu" is executed a menu with the caption "hello" should be created in the menu class "menu". What happens though is that it creates a menu with the caption @test. That is @test isnt expanded. You need to check in the settings editor to verify this as when you right-click it'll expand the variable, but then it might be the wrong caption.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Oct 03, 2004 4:58 pm   
 
Quote:
I have even tried using the [] syntax

Well actually you want <> to force expansion not [] to force evaluation But that doesn't work either.... I would have to agree that you are correct in assuming that #MENU doesnt expand. Weather or not this is intentional I dunno, Because thinking about it the correct syntax for making the caption be a variable would be @@test right (I think that is how delayed expansion works)
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Oct 03, 2004 6:45 pm   
 
Yes, #MENU like most other setting creation commands treats some parameters literally. I am trying to think of a nice way to put this into the help, but it is starting to get crowded with links. I may yet come up with something. Of course that means adding that to every command and function topic, and the wonderful pleasure of researching all those that the typing in the command/function wizard leaves unclear.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Oct 03, 2004 7:33 pm   
 
Quote:
When #menu @test {#echo test} "menu" is executed a menu with the caption "hello" should be created in the menu class "menu".

WRONG! There might be people who actually want their menu captions to be variables (and their menu actions also), so that their menus can be quickly changed by just altering the variables. This is far more likely than people who want to make menu items without knowing what the caption will be. Anyone who does know what the caption should be could, of course, just use the actual caption instead of first putting it in @test.

"Problems" like this usually come up when someone is trying to "simplify" zMUD for someone else, by writing aliases so that a beginner will be able to do all the things that an advanced user can without having to learn all the things an advanced user knows. It seldom works. zMUD already has a good, logical, command structure and attempts to rewrite it usually increase the complexity rather than reducing it.

What you want can be done quite easily with #EXEC. Yes, the syntax checker will report an error but just ignore it. You are either advanced enough to write good syntax without the checker or you shouldn't be trying to do stuff like this.
#EXEC {#MENU @test {#ECHO test} "menu"}}
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Sun Oct 03, 2004 8:59 pm   
 
LightBulb wrote:

"Problems" like this usually come up when someone is trying to "simplify" zMUD for someone else, by writing aliases so that a beginner will be able to do all the things that an advanced user can without having to learn all the things an advanced user knows. It seldom works. zMUD already has a good, logical, command structure and attempts to rewrite it usually increase the complexity rather than reducing it.

In this case I actually try to make menus dynamically as portals are created. That way I can easily know what portals are active.

Quote:

What you want can be done quite easily with #EXEC. Yes, the syntax checker will report an error but just ignore it. You are either advanced enough to write good syntax without the checker or you shouldn't be trying to do stuff like this.
#EXEC {#MENU @test {#ECHO test} "menu"}}

I guess this is a bug in the syntax checker? I use to say that if you never dare to try new stuff, you'll probably never learn them Wink.
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