Manual:DIL Manual/strdir()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 13:08, 27 May 2020 by Nove (talk | contribs) (XML import)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Function:  stringlist strdir( match : string ) ;
  match
         The wild card file you want to match or '*' for all.
  return
         a Stringlist with all the filenames that match the 'match' argument.
The 'match' argument uses the same wild cards as the Linux 'ls' command
so the following will work.
  &ast;
         Match any character or group of characters
  &quest;
         Match one of any character
  [...]
         Match one of a set of characters
Example:

---~---~---~---~---~---~---~---~---
"corpse*" matches:  corpse.10938 corpse.whistler corpseofwhistler ...
"corpse?" matches corpse1 corpses corpse5 ...
"[abc]*" matches ability about cost back ...
"[a-z]*" about zoo man father ...
"start[nm]end" matches startnend startmend
---~---~---~---~---~---~---~---~---

Example DIL:

---~---~---~---~---~---~---~---~---
dilbegin wanted ();
var
        wantedlist:stringlist;
        templist:stringlist;
        i:integer;
        ln:integer;
code
{
        wantedlist := strdir ("dead*");
                i := 0;
                ln := length (wantedlist);
        while (i < ln )
                {
                templist := split (wantedlist.[i],".");
                sendtext (templist.[1]+" wanted dead!&n",self);
                i:=i+1;
                }
quit;
}
dilend


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

The previous DIL would be an example of a command to check the wanted dead
players on the VME if you saved the files with the first word being
'dead' and separated it with a '.' and the players name. For example if
'whistler' was wanted dead  the file name would be 'dead.whistler'