Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   loadIni2() - loadIni() replica (https://forums.graalonline.com/forums/showthread.php?t=79417)

xXziroXx 04-14-2008 09:52 PM

loadIni2() - loadIni() replica
 
Since I couldn't get loadIni() to work, and I don't want to halt my script until I find out why, I decided to script my own version of it. Should work the exact same way loadIni() is intended too.

PHP Code:

function loadini2(file)
{
  
temp.data.loadlines(file);
  
temp.var = new TStaticVar();
  
  for (
temp.linetemp.data) {
    if (
temp.line.starts("[")) {
      
this.preffix temp.line.substring(1temp.line.length() - 2);
      continue;
    } else if (
temp.line.tokenize("=").size() < 2) continue;
    
    
temp.str temp.line.tokenize("=")[0];
    
temp.var.(@this.preffix).(@temp.str) = temp.line.substring(temp.str.length() + 1temp.line.length());
  }
  
  return 
temp.var;


Use it with:
PHP Code:

this.var = loadIni2(path/to/file/filename.ext); 

Example of .ini file:
PHP Code:

[slotA]
charname=Rawr
level
=17

[slotB]
charname=Roar
level
=

this.var.slotA.charname would echo "Rawr".

Chompy 04-14-2008 10:10 PM

Inverness made one though, back in August 07.
His supports loading and saving of ini files, http://forums.graalonline.com/forums...ad.php?t=76374

xXziroXx 04-14-2008 10:13 PM

Oh, I wasn't aware of it, just figured I'd post what I made - no pun intended Inverness.

cbk1994 04-14-2008 10:39 PM

Quote:

Originally Posted by Chompy (Post 1385995)
Inverness made one though, back in August 07.
His supports loading and saving of ini files, http://forums.graalonline.com/forums...ad.php?t=76374

I thought someone made one when I read his other thread.

TiNI file or something ...

Chompy 04-14-2008 11:05 PM

Quote:

Originally Posted by cbkbud (Post 1386006)
I thought someone made one when I read his other thread.

TiNI file or something ...

TIniFile? Inverness made that..


All times are GMT +2. The time now is 04:31 AM.

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