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

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
 
Line 1: Line 1:
 +
==Intlist==
 +
  Intlists are an array of integer types.  They can be set directly as follows:
  
 +
===Example===
 +
  wpn:={5,3,6,9,3,9};
  
<span id="intlist"></span>
+
The intlists can be accessed in the same way stringlist are accessed as follows.
'''Intlist:'''
 
  
  Intlists are an array of integer types. They can be set directly as follows:
+
===Example===
 +
  if (wpn.[5]==5)
 +
  {
 +
    do something
 +
  }
  
'''Example'''
+
The intlists are saved on savable units.
  
  wpn:={5,3,6,9,3,9};
+
'''Type: '''<i><!--CODE-->intlist</i><!--ENDCODE-->
  
The intlists can be accessed in the same way stringlist are accessed as follows.
+
This variable type allows you to keep an ordered list of integers with out
 +
having to create a variable for each integer.
  
'''Example'''
+
===Example===
 +
Setting an intlist
 +
  myintlist:={1,5,9,2,8,5};
 +
  myintlist.[4]:=50;
  
if (wpn.[5]==5)
+
If you set a index that is higher then the highest index you'll get an OOB error.
{
 
do something
 
}
 
  
The intlists are saved on savable units.
+
===Example===
 +
Using intlists
 +
  if (myintlist.[5]==5){
 +
    stuff
 +
  }
  
'''Type:  '''<i><!--CODE-->intlist</i><!--ENDCODE-->
+
  if (myintlist&lt;myint){
 +
    stuff
 +
  }
  
  This variable type allows you to keep an ordered list of integers with out
+
  i:=0;
having to create a variable for each integer.
+
  ln:=length(myintlist);
'''Example:'''  <i><!--CODE-->Setting an intlist</i><!--ENDCODE-->
+
  while (i&lt;ln) {
<i><!--CODE-->
+
    myintlist.[i]:=i;
---~---~---~---~---~---~---~---~---
+
    i:=i+1;
 +
  }
  
myintlist:={1,5,9,2,8,5};
+
===See Also===
myintlist.[10]:=50;
+
::[[insert|Insert]]
 
+
::[[remove|Remove]]
---~---~---~---~---~---~---~---~---
+
::[[extraptr|Extraptr]]
 
 
</i><!--ENDCODE-->
 
 
 
  If you set a index that is higher then the highest index, every index in
 
between will be set to zero.  For example if you only have two values in the
 
intlist and you set index value 10 to 50 all indexes between 2 and 10 will be
 
set to 0.
 
'''Example:'''  <i><!--CODE-->Using intlists</i><!--ENDCODE-->
 
<i><!--CODE-->
 
---~---~---~---~---~---~---~---~---
 
 
 
if (myintlist.[5]==5){
 
stuff
 
}
 
 
 
if (myintlist&lt;myint){
 
stuff
 
}
 
 
 
i:=0;
 
ln:=length(myintlist);
 
while (i&lt;ln){
 
myintlist.[i]:=i;
 
i:=i+1;
 
}
 
 
 
---~---~---~---~---~---~---~---~---
 
 
 
</i><!--ENDCODE-->
 
'''See Also:'''
 
[[#bpinsert|Insert]]
 
[[#bpremove|Remove]]
 
[[#eptr|Extraptr]]
 

Revision as of 10:44, 29 November 2025

Intlist

 Intlists are an array of integer types.  They can be set directly as follows:

Example

 wpn:={5,3,6,9,3,9};

The intlists can be accessed in the same way stringlist are accessed as follows.

Example

 if (wpn.[5]==5)
 {
    do something
 }

The intlists are saved on savable units.

Type: intlist

This variable type allows you to keep an ordered list of integers with out having to create a variable for each integer.

Example

Setting an intlist

 myintlist:={1,5,9,2,8,5};
 myintlist.[4]:=50;

If you set a index that is higher then the highest index you'll get an OOB error.

Example

Using intlists

 if (myintlist.[5]==5){
   stuff
 }
 if (myintlist<myint){
   stuff
 }
 i:=0;
 ln:=length(myintlist);
 while (i<ln) {
   myintlist.[i]:=i;
   i:=i+1;
 }

See Also

Insert
Remove
Extraptr