|
|||
|
is it possible to read key value pairs from a .ini file that contains no section names?
I know it would be easy to change the ini and add a section name, but in this instance I can't. ini format is Code:
; startup xbox debug monitor (needs sdk installed) startDebug = 0 ; enable igr igrEnabled = 1 ; display flubber anim doStartupAnimation = 1 ; do dvd drive check doDvdDriveCheck = 0 ; do not reset when pressing on eject noResetOnEject = 1 Code:
var iniPath = getAppDir()+"x2config.ini"; var iniFile = new Ini(iniPath); var dash1Name = iniFile.getInt(null,"igrEnabled"); trace(dash1Name);
__________________
Awaiting Swf Kit V3 |
|
|||
|
Nevermind, I figured it out.
I just loaded the ini file as a string and prepended a section name, saved that as a temp file, then read it back as a normal ini file. Code:
var iniPath = Dialogs.fileOpen("Ini files(*.ini)|*.ini", "", "", false);
var tmpPath = Shell.getSpecialFolder("temp")+"\\temp_x2config.ini"
var iniString = "[Default]\r\n"
iniString = iniString+StringStream.readFromFile(iniPath);
var tmpFile = new StringStream();
tmpFile.write(iniString);
tmpFile.saveToFile(tmpPath)
tmpFile.close();
var readFile = new Ini(tmpPath);
var tmpRead = readFile.getSection("Default");
for (i=0; i<tmpRead.length;i++){
var tmpKey = tmpRead[i].substr(0,tmpRead[i].lastIndexOf("="));
var tmpValue = tmpRead[i].substr(tmpRead[i].indexOf("=")+1,tmpRead[i].length);
// Arrary Push code here...
trace("Key: "+tmpKey+" - Value: "+tmpValue);
}
__________________
Awaiting Swf Kit V3 |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|