Jump to content


Sam_Man_5000

Member Since 08 Jul 2009
Offline Last Active Mar 12 2014 07:41 PM

Posts I've Made

In Topic: Deleting Key'S In Ini Files

21 January 2014 - 09:40 PM

Never mind! Solved the issue! +1'd your posts, thanks for the help, bro!


In Topic: Deleting Key'S In Ini Files

21 January 2014 - 05:49 PM

Hey there, pardon the late response here.

 

The code works perfectly, until I apply it to my own version of the code.

 

 

What I'm doing is I'm using an object to define each key with a value.

Then when that object is right clicked I'm telling another object via the means of a variable which key to delete.

It deletes the requested key, and then deletes every key past that one. Any ideas?

 

 

My code for deleting keys:

if docheck=true
{
docheck=false
//Now the manipulation:
//now remove key 3
nr = global.sendnumber
maxnr = global.linenumber-1;//max number of keys. Array needs to be of the same max size.

//This'll shift all values below removed key up one place.
for (i = nr; i < maxnr; i += 1)
{
    if (i < maxnr-1)
    {
        global.text_array[i] = global.text_array[i+1];
    }
}
//The above code may not be the most efficient way of doing it.

//By now the array contains the new values.
//Now just wipe the ini file and store these new values using a for loop:
file_delete("FinalCode.ini");

ini_open("FinalCode.ini");//create new ini

ini_write_real("Code","LineCount",global.linenumber)
for (i = 0; i < maxnr-1; i += 1)//here is is
{
    ini_write_string("Code", string(i), string(global.text_array[i]));
}
ini_close();//close it up

}

In Topic: Deleting Key'S In Ini Files

21 January 2014 - 04:03 PM

EX: 

[Dialog]
0=Hello
1=There
2=Friend
3=Are
4=You
5=

[Off topic: Good to see another South African developer here :)]


In Topic: Deleting Key'S In Ini Files

21 January 2014 - 04:00 PM

Very good! It does everything intended, but alas it still inserts "5=" and then leaves it blank. Any idea why? I've searched the code and can't seem to find out why it's still doing that.

In Topic: Deleting Key'S In Ini Files

21 January 2014 - 03:48 PM

Okay! Thanks so much for the help! I will try to apply this to my current code and see if it works out.