Difference between revisions of "Manual:DIL Manual/Assignment"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
 
m
 
Line 3: Line 3:
 
<span id="assgn"></span>
 
<span id="assgn"></span>
  
  <h3>'''Assignment:'''</h3>
+
  <h3>Assignment:</h3>
 
     You can assign values to the variables you declare
 
     You can assign values to the variables you declare
 
     in your 'var' section, and some of the built-in
 
     in your 'var' section, and some of the built-in

Latest revision as of 14:14, 29 June 2020


Assignment:

    You can assign values to the variables you declare
    in your 'var' section, and some of the built-in
    variables. This is  done by the ':=' operator.
    Note that you can also assign a variable the result
    of an expression
    (the addition of strings below as an example)
Example:

   dilbegin foo();
   var
     myvarsl : stringlist;
     myvars : string;
   code
   {
     :start:
     myvarsl := {"a string","another","the first"};
     myvars := self.name+" XX ";
     myvarsl.[2] := "the last";
     myvarsl.[3] := "illegal";  /* Will not work since [3] is not defined */
     pause;
     goto start:
   }
   dilend