Home
About
Policies
FAQ
Forums
Registration
Password Recovery

With (MPI)

From Tapestries MUCK

(Difference between revisions)
Jump to: navigation, search
(fixed arrows to « instead of <)
 
(3 intermediate revisions not shown)
Line 1: Line 1:
-
[[Category:MPI functions]]
+
[[Category:functions (MPI)]][[Category:Variable Handling Functions (MPI)]]
=with=
=with=
<mpi>{with:var,val,expr..}</mpi>
<mpi>{with:var,val,expr..}</mpi>
This defines a new variable with the given name, and sets it's value to the given val.
This defines a new variable with the given name, and sets it's value to the given val.
-
Up to 7 expr's are allowed, but the only value returned to {with}'s caller, is the value returned by the evaluation of the last expr.  If there is already a variable of the same name, then this command will override that variable, for the duration of the {[[With (MPI)|with]]:} command.
+
Up to 7 expr's are allowed, but the only value returned to {[[With (MPI)|with]]}'s caller, is the value returned by the evaluation of the last expr.  If there is already a variable of the same name, then this command will override that variable, for the duration of the {[[With (MPI)|with]]:} command.
The new variable is only valid to use within the confines of the {[[With (MPI)|with]]:} command, and it will go away after the command completes.
The new variable is only valid to use within the confines of the {[[With (MPI)|with]]:} command, and it will go away after the command completes.
Line 12: Line 12:
Here's an example to illustrate the scope of variables inside of {[[With (MPI)|with]]:} commands:
Here's an example to illustrate the scope of variables inside of {[[With (MPI)|with]]:} commands:
-
<mpi>    {prop:_mydesc}                          <- {&people} not defined.
+
<mpi>    {prop:_mydesc}                          «- {&people} not defined.
-
     {with:people,{contents:here,players},    <- Defining.  Not available yet.
+
     {with:people,{contents:here,players},    «- Defining.  Not available yet.
-
         {if:{count:{&people}},              <- It's usable now.
+
         {if:{count:{&people}},              «- It's usable now.
             The players awake here are
             The players awake here are
-
             {lit: }                          <- just puts in a space.
+
             {lit: }                          «- just puts in a space.
             {commas:{&people},{lit: and },
             {commas:{&people},{lit: and },
-
                 who,{name:{&who}}            <- uses {&who} as temp var.
+
                 who,{name:{&who}}            «- uses {&who} as temp var.
-
             }                                <- {&who} no longer defined.
+
             }                                «- {&who} no longer defined.
         }
         }
-
     }                                        <- {&people} no longer defined.
+
     }                                        «- {&people} no longer defined.
</mpi>
</mpi>

Latest revision as of 20:31, 24 April 2007

with

{with:var,val,expr..}

This defines a new variable with the given name, and sets it's value to the given val.

Up to 7 expr's are allowed, but the only value returned to {with}'s caller, is the value returned by the evaluation of the last expr. If there is already a variable of the same name, then this command will override that variable, for the duration of the {with:} command.

The new variable is only valid to use within the confines of the {with:} command, and it will go away after the command completes.


This provides scoped variables quite effectively. NOTE: There can be no more than 32 variables defined at any one time, total. This includes variables that are defined within macros, or properties or lists that are executed with {exec:} or {lexec:}.

Here's an example to illustrate the scope of variables inside of {with:} commands:

     {prop:_mydesc}                           «- {&people} not defined.
     {with:people,{contents:here,players},    «- Defining.  Not available yet.
         {if:{count:{&people}},               «- It's usable now.
             The players awake here are
             {lit: }                          «- just puts in a space.
             {commas:{&people},{lit: and },
                 who,{name:{&who}}            «- uses {&who} as temp var.
             }                                «- {&who} no longer defined.
         }
     }                                        «- {&people} no longer defined.
 
Personal tools
Namespaces
Variants
Actions
navagation
information
wiki
Toolbox