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

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="bfdelstr"></span>
+
= delstr() =
 +
'''Function''' (integer). Deletes a string file.
  
−
  '''Function:'''  <i><!--CODE-->integer delstr( filename : string ) ;</i><!--ENDCODE-->
+
  delstr(filename : string)
  
−
<!--TERM-->  '''filename'''
+
Deletes a file written by [[Manual:DIL Manual/savestr()|savestr()]] and read by
−
<!--DEFINITION-->        The name of the String file to be deleted
+
[[Manual:DIL Manual/loadstr()|loadstr()]]: boards, clans and competitions use it to remove
−
<!--TERM-->  '''Return'''
+
messages and lists.
−
<!--DEFINITION-->        Returns an integer TRUE if deleted FALSE if not
 
  
−
The delstr is used to delete files that are used with the 'loadstr' and
+
== Parameters ==
−
'savestr'      functions.  The delstr function will only delete files that
+
{| class="wikitable"
−
each individual Zone has access to which is set up in the Zonelist file in the
+
! Name !! Type !! Meaning
−
VME etc directory.
+
|-
−
'''Example:'''
+
| filename || string || The file's name, as given to <code>savestr()</code>: letters, digits, <code>_</code> and <code>.</code> only, at most 512 characters.
−
<i><!--CODE-->
+
|}
−
---~---~---~---~---~---~---~---~---
 
  
−
dilbegin news|del ("arg : string /*filename to be deleted);
+
== Returns ==
−
var
+
integer. As the server is now, FALSE (0) when the file was deleted and TRUE (1) when it wasn't (no such file); the opposite of what the name suggests. FALSE as well for a name with other characters. Don't rely on the value: no zone does, and it may be corrected. Use <code>loadstr()</code> first to see whether the file exists.
−
        ret:integer;/*to hold the return value if deleted or not*/
 
−
code
 
−
dilend
 
−
 
 
−
 
 
−
---~---~---~---~---~---~---~---~---
 
−
 
 
−
</i><!--ENDCODE-->
 
−
'''See Also''' <i><!--CODE-->
 
−
[[#bfloadstr|Load String file]] and
 
−
[[#bfsavestr|Save String file]]</i><!--ENDCODE-->
 
−
<span id="bfdelstr"></span>
 
−
 
 
−
'''Function:'''  <i><!--CODE-->integer delstr( filename : string ) ;</i><!--ENDCODE-->
 
−
 
 
−
<!--TERM-->  '''filename'''
 
−
<!--DEFINITION-->        The name of the String file to be deleted
 
−
<!--TERM-->  '''Return'''
 
−
<!--DEFINITION-->        Returns an integer TRUE if deleted FALSE if not
 
  
−
The delstr is used to delete files that are used with the 'loadstr' and
+
== Notes ==
−
'savestr'      functions. The delstr function will only delete files that
+
* The file is in the <code>strings</code> folder of the zone's DIL file directory (the last column of the zone's line in <code>vme/etc/zonelist</code>), or of <code>dil_file_dir</code> in <code>server.cfg</code> when the zone has none.
−
each individual Zone has access to which is set up in the Zonelist file in the
+
* Only zones with access level 10 or less (the fourth column of <code>zonelist</code>) may use it. In other zones the program stops and the zone log says "attempt to violate system access security (delstr)".
−
VME etc directory.
+
* A name with other characters (a <code>/</code>, a space) is refused with a line in the zone log.
−
'''Example:'''
+
* The result fails (it is neither true nor false) when the argument does, e.g. a field of a null unit.
−
<i><!--CODE-->
 
−
---~---~---~---~---~---~---~---~---
 
  
−
dilbegin news|del ("arg : string /*filename to be deleted);
+
== Example ==
−
var
+
<pre>
−
        ret:integer;/*to hold the return value if deleted or not*/
+
dilbegin clear_notes(pc : unitptr);
−
code
+
var
 +
  fn : string;
 +
  s : string;
 +
  i : integer;
 +
code
 +
{
 +
  fn := tolower(pc.name) + ".notes";
 +
  i := loadstr(fn, s);
 +
  if (i < 1)
 +
  {
 +
      sendtext("You have no notes.<br/>", pc);
 +
      return;
 +
  }
 +
  i := delstr(fn);               // the result can't be trusted, see Returns
 +
  sendtext("Your notes are deleted.<br/>", pc);
 +
  return;
 +
}
 
dilend
 
dilend
 +
</pre>
 +
Deletes a player's notes file, after <code>loadstr()</code> has shown that there is one.
  
−
 
+
== See also ==
−
---~---~---~---~---~---~---~---~---
+
* [[Manual:DIL Manual/savestr()|savestr()]]
−
 
+
* [[Manual:DIL Manual/loadstr()|loadstr()]]
−
</i><!--ENDCODE-->
+
* [[Manual:DIL Manual/delunit()|delunit()]]
−
'''See Also''' <i><!--CODE-->
 
−
[[#bfloadstr|Load String file]] and
 
−
[[#bfsavestr|Save String file]]</i><!--ENDCODE-->
 

Latest revision as of 23:21, 14 November 2026

delstr()

Function (integer). Deletes a string file.

delstr(filename : string)

Deletes a file written by savestr() and read by loadstr(): boards, clans and competitions use it to remove messages and lists.

Parameters

Name Type Meaning
filename string The file's name, as given to savestr(): letters, digits, _ and . only, at most 512 characters.

Returns

integer. As the server is now, FALSE (0) when the file was deleted and TRUE (1) when it wasn't (no such file); the opposite of what the name suggests. FALSE as well for a name with other characters. Don't rely on the value: no zone does, and it may be corrected. Use loadstr() first to see whether the file exists.

Notes

  • The file is in the strings folder of the zone's DIL file directory (the last column of the zone's line in vme/etc/zonelist), or of dil_file_dir in server.cfg when the zone has none.
  • Only zones with access level 10 or less (the fourth column of zonelist) may use it. In other zones the program stops and the zone log says "attempt to violate system access security (delstr)".
  • A name with other characters (a /, a space) is refused with a line in the zone log.
  • The result fails (it is neither true nor false) when the argument does, e.g. a field of a null unit.

Example

dilbegin clear_notes(pc : unitptr);
var
   fn : string;
   s : string;
   i : integer;
code
{
   fn := tolower(pc.name) + ".notes";
   i := loadstr(fn, s);
   if (i < 1)
   {
      sendtext("You have no notes.<br/>", pc);
      return;
   }
   i := delstr(fn);                // the result can't be trusted, see Returns
   sendtext("Your notes are deleted.<br/>", pc);
   return;
}
dilend

Deletes a player's notes file, after loadstr() has shown that there is one.

See also