Manual:DIL Manual/loadstr()

From DikuMUD Wiki
Jump to navigation Jump to search


Function:
integer loadstr( filename : string , buff : string );
  filename
         The name of the string file to be loaded
  buff
         The string that you wish to read the file contents into
  Return
         FILE_LOADED, FILE_NOT_FOUND, FILE_OUT_OF_MEMORY,or FILE_TO_LARGE
Loadstr is used to load strings from disk that were saved either by savestr
or any text editor.
The 'loadstr' is perfect for operations such as
on-line edited newspaper, a lottery where the tickets are sold to players,
creating smarter NPC's that can remember through reboots who they are hunting,
Dil based teachers, message boards, mail system, news command., zone or
room based help,  competition boards, and much much more.
Disk access is always slow.
attempt to keep file sizes to a minimum for quick loading.  Otherwise you
might cause serious delays on the server.
Example:

---~---~---~---~---~---~---~---~---
dilbegin news_load ();
var
        ret:integer;/*to hold the return value if loaded or not*/
        buff:string;/*to hold the loaded string*/
code
{
ret:= loadstr("news.txt",buff);
if (!ret)
        {
        log ("File not read.");
        quit;
        }
sendtext(buff+"[&]n",self);
quit;/*dil load routine done destroy self.*/
}
dilend
---~---~---~---~---~---~---~---~---

See Also 
Delete a String file and
Save String file
---~---~---~---~---~---~---~---~---