Manual:DIL Manual/insert()
Jump to navigation
Jump to search
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
{
if (length(sl)==0)
{
addstring (sl,s);
return (sl);
}
ln:=length(s);
i:=0;
while (i<ln)
{
if (length(sl.[i]) <=ln)
{
insert (sl,i,s);
return(sl);
}
i:=i+1;
}
addstring (sl,s); return (sl); } dilend
---~---~---~---~---~---~---~---~---
---~---~---~---~---~---~---~---~---