Indeed, this is meant to be joined to a TStaticVar
Lines starting with ; are comments.
Lines starting with = are appended to last line.
PHP Code:
public function load(filename) {
temp.file = 0;
temp.i = 0;
temp.key = 0;
temp.e = 0;
temp.var = 0;
temp.val = 0;
this.keys = {};
if (filename == null) {
return;
}
file.loadlines(filename);
if (file.size() < 1) {
return;
}
for (i = 0; i < file.size(); i ++) {
if (file[i].starts(";"))
continue;
if (!(file[i].starts("[") && file[i].ends("]"))) {
if (key == null)
continue;
e = file[i].pos("=");
if (e < 0)
continue;
if (e == 0) {
val = file[i].substring(1, -1);
this.(@ key).(@ var) @= val;
}
else {
var = file[i].substring(0, e);
val = file[i].substring(e+1, -1);
this.(@ key).(@ var) = val;
}
}
else {
key = file[i].substring(1, file[i].length() - 2);
if (
key in {
"keys",
"initialized",
"ispaused",
"joinedclasses",
"maxlooplimit",
"name",
"scripterrors",
"scriptlogmissingfunctions",
"timeout",
"objecttype"
}
) key @= "_";
this.keys.add(key);
}
}
}
public function save(filename) {
temp.output = 0;
temp.i = 0;
temp.e = 0;
temp.keys = this.getdynamicvarnames();
temp.vars = 0;
keys.remove("objecttype");
for (i = 0; i < keys.size(); i ++) {
if (this.(@ keys[i]).type() != -1) continue;
if (keys[i] == null) continue;
output.add("[" @ keys[i] @ "]");
vars = this.(@ keys[i]).getdynamicvarnames();
for (e = 0; e < vars.size(); e ++) {
if (this.(@ keys[i]).(@ vars[e]) != null) {
output.add(vars[e] @ "=" @ this.(@ keys[i]).(@ vars[e]));
}
}
}
output.savelines(filename, 0);
}
public function clearkey(keyname) {
temp.i = 0;
temp.vars = 0;
vars = this.(@ keyname).getdynamicvarnames();
for (i = 0; i < vars.size(); i ++) {
this.(@ keyname).(@ vars[i]) = null;
}
}
public function copyvars(object, keyname) {
if (object.type() != 2) return;
for (temp.i: this.(@ keyname).getdynamicvarnames()) {
object.(@ i) = this.(@ keyname).(@ i);
}
}
public function objecttype() {
return "TIniFile";
}