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

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
 
(XML import)
 
Line 1: Line 1:
 
 
 
<span id="bfstrdir"></span>
 
<span id="bfstrdir"></span>
  
Line 44: Line 42:
 
         ln:integer;
 
         ln:integer;
 
  code
 
  code
  {
+
dilend
 +
 
 +
 
 +
  ---~---~---~---~---~---~---~---~---
 +
 
 +
</i><!--ENDCODE-->
 +
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'
 +
<span id="bfstrdir"></span>
 +
 
 +
'''Function:'''  <i><!--CODE-->stringlist strdir( match : string ) ;</i><!--ENDCODE-->
 +
 
 +
<!--TERM-->  '''match'''
 +
<!--DEFINITION-->        The wild card file you want to match or '*' for all.
 +
<!--TERM-->  '''return'''
 +
<!--DEFINITION-->        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.
 +
 
 +
<!--TERM-->  '''&ast;'''
 +
<!--DEFINITION-->        Match any character or group of characters
 +
<!--TERM-->  '''&quest;'''
 +
<!--DEFINITION-->        Match one of any character
 +
<!--TERM-->  '''[...]'''
 +
<!--DEFINITION-->        Match one of a set of characters
  
        wantedlist := strdir ("dead*");
+
'''Example:'''
 +
<i><!--CODE-->
 +
---~---~---~---~---~---~---~---~---
  
                i := 0;
+
"corpse*" matches: corpse.10938 corpse.whistler corpseofwhistler ...
                ln := length (wantedlist);
+
"corpse?" matches corpse1 corpses corpse5 ...
 +
"[abc]*" matches ability about cost back ...
 +
"[a-z]*" about zoo man father ...
 +
"start[nm]end" matches startnend startmend
  
        while (i &lt; ln )
+
---~---~---~---~---~---~---~---~---
                {
 
                templist := split (wantedlist.[i],".");
 
                sendtext (templist.[1]+" wanted dead!&amp;n",self);
 
                i:=i+1;
 
                }
 
  
  quit;
+
  </i><!--ENDCODE-->
  }
+
'''Example DIL:'''
  dilend
+
<i><!--CODE-->
 +
---~---~---~---~---~---~---~---~---
 +
 
 +
dilbegin wanted ();
 +
  var
 +
        wantedlist:stringlist;
 +
        templist:stringlist;
 +
        i:integer;
 +
        ln:integer;
 +
  code
 +
dilend
  
  

Latest revision as of 22:32, 4 December 2025

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

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'

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

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'