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

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
 
(XML import)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
<span id="assgn"></span>
  
 +
<h3>'''Assignment:'''</h3>
 +
    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:'''
 +
 +
<nowiki>
 +
 +
  dilbegin foo();
 +
  var
 +
    myvarsl : stringlist;
 +
    myvars : string;
 +
  code
 +
dilend</nowiki>
 
<span id="assgn"></span>
 
<span id="assgn"></span>
  
Line 20: Line 38:
 
     myvars : string;
 
     myvars : string;
 
   code
 
   code
  {
+
dilend</nowiki>
    :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</nowiki>
 

Latest revision as of 22:35, 4 December 2025

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
dilend

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
dilend