AGSScriptModuleKitaiHelper to store plain String data into filesDataFile1.0oString goodparam(String input, String param) { int index = input.IndexOf(":"); if ((index < 0) || (input.Substring(0, index) != param)) return null; return input.Substring(index+1, input.Length - index); } bool DataFile::Open(String file, String separator) { if (String.IsNullOrEmpty(separator)) return false; if (!File.Exists(file)) { File* tmp = File.Open(file, eFileWrite); if (tmp == null) return false; tmp.Close(); } this.file = file; this.sep = separator; return true; } String DataFile::GetParam(String param) { File* file = File.Open(this.file, eFileRead); if (file == null) return null; while (!file.EOF) { String ret = goodparam(file.ReadRawLineBack(), param); if (ret != null) { file.Close(); return ret; } } file.Close(); return ""; } bool DataFile::SetParam(String param, String value) { File* file = File.Open(this.file, eFileRead); if (file == null) return false; String tmp_name = "tmp"; while (File.Exists(tmp_name)) { tmp_name = tmp_name.Append("_tmp"); } File* tmp = File.Open(tmp_name, eFileWrite); if (tmp == null) return false; while (!file.EOF) { if (file.Error) return false; tmp.WriteRawLine(file.ReadRawLineBack()); } tmp.Close(); file.Close(); file = File.Open(this.file, eFileWrite); tmp = File.Open(tmp_name, eFileRead); if (file == null || tmp == null) return false; String line = ""; bool ecrit = false; while (!tmp.EOF) { line = tmp.ReadRawLineBack(); if (tmp.Error) return false; if (goodparam(line, param) != "") { file.WriteRawLine(String.Format("%s%s%s", param, this.sep, value)); ecrit = true; } else file.WriteRawLine(line); } if (!ecrit) file.WriteRawLine(String.Format("%s%s%s", param, this.sep, value)); tmp.Close(); file.Close(); File.Delete(tmp_name); return true; } int DataFile::GetInt(String param) { String value = this.GetParam(param); return value.AsInt; } bool DataFile::SetInt(String param, int value) { return this.SetParam(param, String.Format("%d",value)); }ästruct DataFile { String file; protected String sep; /// Opens a data-file to store information. Will create it if does not yet exist. import bool Open(String file, String separator); /// Gets the String value of PARAMETER from the data-file. import String GetParam(String parameter); /// Stores the String VALUE as the value of PARAMETER. Will overwrite the value if PARAMETER is already set. import bool SetParam(String parameter, String value); /// Gets the String value of PARAMETER from the data-file and converts it into an int. import int GetInt(String parameter); /// Converts the int VALUE into a String to store it as the value of PARAMETER. import bool SetInt(String parameter, int value); };Æá2-ej÷´