Difference between revisions of "Manual:DIL Manual/insert()"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
 
(XML import)
 
Line 1: Line 1:
 +
<span id="bpinsert"></span>
 +
 +
'''Function:  '''<i><!--CODE-->insert( sl : &lt;stringlist or intlist&gt;, i : integer, s : string ) ;</i><!--ENDCODE-->
 +
 +
<!--TERM-->  '''sl'''
 +
<!--DEFINITION-->        the stringlist or intlist you are inserting to
 +
<!--TERM-->  '''i'''
 +
<!--DEFINITION-->        the index where you want to insert the string
 +
<!--TERM-->  '''s'''
 +
<!--DEFINITION-->        the string you want to insert
 +
 +
This function allows you to insert a string in a stringlist or intlist
 +
with out re-writing the entire stringlist or intlist to do it.  The
 +
following Dil will add a string in order to a stringlist.
 +
'''Example:'''
 +
<i><!--CODE-->
 +
---~---~---~---~---~---~---~---~---
  
 +
dilbegin stringlist add_in_order (sl:stringlist,s:string);
 +
var
 +
  i:integer;
 +
  ln:integer;
 +
code
 +
dilend
  
 +
---~---~---~---~---~---~---~---~---
 +
 +
</i><!--ENDCODE-->
 +
 +
 +
 +
---~---~---~---~---~---~---~---~---
 
<span id="bpinsert"></span>
 
<span id="bpinsert"></span>
  
Line 24: Line 54:
 
   ln:integer;
 
   ln:integer;
 
  code
 
  code
{
+
dilend
if (length(sl)==0)
 
  {
 
  addstring (sl,s);
 
  return (sl);
 
  }
 
 
 
ln:=length(s);
 
i:=0;
 
while (i&lt;ln)
 
  {
 
  if (length(sl.[i]) &lt;=ln)
 
  {
 
  insert (sl,i,s);
 
  return(sl);
 
  }
 
  i:=i+1;
 
  }
 
 
 
addstring (sl,s);
 
return (sl);
 
}
 
dilend
 
  
 
  ---~---~---~---~---~---~---~---~---
 
  ---~---~---~---~---~---~---~---~---

Latest revision as of 22:32, 4 December 2025

Function:  insert( sl : <stringlist or intlist>, i : integer, s : string ) ;
  sl
         the stringlist or intlist you are inserting to
  i
         the index where you want to insert the string
  s
         the string you want to insert
This function allows you to insert a string in a stringlist or intlist
with out re-writing the entire stringlist or intlist to do it.  The
following Dil will add a string in order to a stringlist.
Example:

---~---~---~---~---~---~---~---~---
dilbegin stringlist add_in_order (sl:stringlist,s:string);
var
 i:integer;
 ln:integer;
code

dilend

---~---~---~---~---~---~---~---~---


---~---~---~---~---~---~---~---~---

Function:  insert( sl : <stringlist or intlist>, i : integer, s : string ) ;
  sl
         the stringlist or intlist you are inserting to
  i
         the index where you want to insert the string
  s
         the string you want to insert
This function allows you to insert a string in a stringlist or intlist
with out re-writing the entire stringlist or intlist to do it.  The
following Dil will add a string in order to a stringlist.
Example:

---~---~---~---~---~---~---~---~---
dilbegin stringlist add_in_order (sl:stringlist,s:string);
var
 i:integer;
 ln:integer;
code

dilend

---~---~---~---~---~---~---~---~---


---~---~---~---~---~---~---~---~---