Difference between revisions of "Manual:DIL Manual/delstr()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = delstr() = | |
| + | '''Function''' (integer). Deletes a string file. | ||
| − | + | delstr(filename : string) | |
| − | + | Deletes a file written by [[Manual:DIL Manual/savestr()|savestr()]] and read by | |
| − | + | [[Manual:DIL Manual/loadstr()|loadstr()]]: boards, clans and competitions use it to remove | |
| − | + | messages and lists. | |
| − | |||
| − | + | == Parameters == | |
| − | + | {| class="wikitable" | |
| − | + | ! Name !! Type !! Meaning | |
| − | + | |- | |
| − | + | | filename || string || The file's name, as given to <code>savestr()</code>: letters, digits, <code>_</code> and <code>.</code> 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 <code>loadstr()</code> first to see whether the file exists. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | == Notes == | |
| − | + | * 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. | |
| − | + | * 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)". | |
| − | + | * A name with other characters (a <code>/</code>, 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 == | |
| − | + | <pre> | |
| − | + | 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 | 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()]] | |
| − | + | * [[Manual:DIL Manual/delunit()|delunit()]] | |
| − | |||
| − | |||
| − | |||
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
stringsfolder of the zone's DIL file directory (the last column of the zone's line invme/etc/zonelist), or ofdil_file_dirinserver.cfgwhen 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.