Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-15-2008, 12:41 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
TIniFile (split from loadIni2() - loadIni() replica)

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.0;
  
temp.key 0;
  
temp.0;
  
temp.var = 0;
  
temp.val 0;
  
this.keys = {};
  
  if (
filename == null) {
    return;
  }
  
file.loadlines(filename);
  if (
file.size() < 1) {
    return;
  }
  for (
0file.size(); ++) {
    if (
file[i].starts(";"))
      continue;
    if (!(
file[i].starts("[") && file[i].ends("]"))) {
      if (
key == null)
        continue;
      
file[i].pos("=");
      if (
0)
        continue;
      if (
== 0) {
        
val file[i].substring(1, -1);
        
this.(@ key).(@ var) @= val;
      }
      else {
        var = 
file[i].substring(0e);
        
val file[i].substring(e+1, -1);
        
this.(@ key).(@ var) = val;
      }
    }
    else {
      
key file[i].substring(1file[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.0;
  
temp.0;
  
temp.keys this.getdynamicvarnames();
  
temp.vars 0;
  
  
keys.remove("objecttype");
  for (
0keys.size(); ++) {
    if (
this.(@ keys[i]).type() != -1) continue;
    if (
keys[i] == null) continue;
    
output.add("[" keys[i] @ "]");
    
vars this.(@ keys[i]).getdynamicvarnames();
    for (
0vars.size(); ++) {
      if (
this.(@ keys[i]).(@ vars[e]) != null) {
        
output.add(vars[e] @ "=" this.(@ keys[i]).(@ vars[e]));
      }
    }
  }
  
output.savelines(filename0);
}
public function 
clearkey(keyname) {
  
temp.0;
  
temp.vars 0;
  
  
vars this.(@ keyname).getdynamicvarnames();
  for (
0vars.size(); ++) {
    
this.(@ keyname).(@ vars[i]) = null;
  }
}
public function 
copyvars(objectkeyname) {
  if (
object.type() != 2) return;
  for (
temp.ithis.(@ keyname).getdynamicvarnames()) {
    
object.(@ i) = this.(@ keyname).(@ i);
  }
}
public function 
objecttype() {
  return 
"TIniFile";

__________________
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.