Author Topic: This saving function won't work.  (Read 289 times)

Code: [Select]
$Pref::BetaList::Active = 1;
$Pref::BetaList::ListName = "list_0";
$Pref::BetaList::AddAutoAdmin = 1;
$Pref::BetaList::AddAutoSuperAdmin = 1;

function betalist_create()
{
$BetaList = new scriptObject(BetaListSO)
{
class = "BetaListSO";
active = $Pref::BetaList::Active;
filePath = "config/server/BetaLists/" @ $Pref::BetaList::ListName @ ".txt";

//--List of values automatically added to any list.
//--By default, only the host is automatically added.
numListed = 1;
bl_id1 = getNumKeyID();
};
if($Pref::BetaList::AddAutoAdmin)
$BetaList.addAutoAdmins();
if($Pref::BetaList::AddAutoSuperAdmin)
$BetaList.addAutoSuperAdmins();
$BetaList.numListed += $BetaList.loadList();
}

function BetaListSO::saveList(%this)
{
if(!%this.numListed)
error("BETALIST: No BL_IDs saved in the SO!"); return;
%file = new fileObject();
%file.openForWrite(%this.filePath);
for(%i = 1; %i < %this.numListed; %i++)
%file.writeLine(%this.bl_id[%i]);
%file.close();
%file.delete();
echo("BETALIST: Saved list" SPC $Pref::BetaList::ListName SPC "into the Beta Lists config folder.");
}

function BetaListSO::loadList(%this)
{
%file = new fileObject();
%file.openForRead(%this.filePath);
for(%lines = 1; !%file.isEOF(); %lines++)
{
if(!%this.isInList(%line = %file.readLine()))
%this.addToList(%line);
else
%failures++;
}
%file.close();
%file.delete();
echo("BETALIST: Loaded list" SPC $Pref::BetaList::ListName SPC "from the Beta Lists config folder.");
return %lines - %failures;
}

It doesn't say there are any syntax errors, but it just doesn't save nor does it echo anything.

What have I done wrong?

Is there some reason you're not just using .save and exec?

for(%i = 1; %i <= %this.numListed; %i++)
Use that, otherwise the last entry will be cut off.

I don't see any other problems.

god dang it i keep forgetting about save lol


thanks amade