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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Mon Sep 27, 2010 5:35 pm   

Local Variable with Prompt [version 3.29b]
 
I posted this in the general forum, but I believe this belongs here. I am reposting.


I looked at the documentation and it doesn't say you can't use a local variable with the prompt command. Should we be able to? I really don't want to have a global variable used because I am going to throw it away when I'm done.

Example:
Code:
Code:

#MENU 10 Add Character{#PR Name "Enter the name of the character";
#addkey friends @Name %selected} Identify


I would like to be able to do this:
Code:
Code:

#MENU 10 Add Character{#local $Name; #PR $Name "Enter the name of the character";
#addkey friends $Name %selected} Identify
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Mon Sep 27, 2010 7:41 pm   
 
You can only use a local variable within a SINGLE LINE on the command line. So you need to use the ; character to put multiple commands together on a single line.
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Mon Sep 27, 2010 9:25 pm   
 
Zugg wrote:
You can only use a local variable within a SINGLE LINE on the command line. So you need to use the ; character to put multiple commands together on a single line.

I did put semi-colons to show they are separated. Here is the code exported in XML. When I high-light the text and select 'Add Character' the prompt doesn't show up.
Code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <menu priority="20">
    <caption>Add Character</caption>
    <value>#local $Name
#pr $Name "Enter the name of the character:"
#addkey friends $Name %selected</value>
  </menu>
</cmud>
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Mon Sep 27, 2010 10:16 pm   
 
The problem is that the #PROMPT command does not support local variables. #PROMPT takes a variable *name* as the first argument, so it is looking in the $Name location variable for the name of the variable and not finding one, so the command aborts.

For using local variables, use the %prompt function:
Code:
$name = %prompt("Enter the name of the character")

and then it should work.

Sorry I misunderstood your original question. I thought you were talking about using local variables on the command line. Silly me.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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