## Recommended Posts

First the material....

Old ini:

```[a]
a1=someinfo1
a2=someinfo2
a3=someinfo3
a4=someinfo4
a5=someinfo5```

New ini(The result i need to get):

```[a]
a1=someinfo1
a2=someinfo3
a3=someinfo4
a4=someinfo5```

My script witch isin't working:

```\$a = "f.ini"
\$z = 0
\$f = 0
\$line = 2;The line witch should be deleted....
Do
\$f = \$f + 1
Until IniRead(\$a, "a", "a" & \$f, "") = ""
Do
\$z = \$z + 1
Until \$line = IniRead(\$a, "a", "a" & \$z, "")
;IniDelete(\$a, "a", "a" & \$z)
Do
\$z = \$z + 1;Somekinda nonsense
\$k = \$z + 1;Somekinda nonsense
\$v = \$z - 1;Somekinda nonsense
IniWrite(\$a, "a", "a" & \$v, IniRead(\$a, "a", "a" & \$k, ""))
Until IniRead(\$a, "a", "a" & \$f, "") = ""```

What i need to do:

I get the number of line witch i need to delete in var \$line so i need a script witch would delete the \$line'th line (in my case now 2 line) and decrease all keys that are more then \$line (in this case 3,4,5) by 1... so i would get (1,2,3,4 with no spaces like 1,3,4,5 but the result of the old key's has not to change...) New ini from old ini....

have no idea how to do this....

I need to do this so because my reading system is so:

```\$x = 0
Do
GuiCtrlSetData(-1, IniRead("f.ini", "a", "a" & \$x, ""))
\$x = \$x + 1
Until IniRead("f.ini", "a", "a" & \$x, "") = ""```

So if i get a space in my ini like a1 a2 a4 .(there will be no a3 key) the script will read only until a2

Hope some1 is smart enought to do this...

Edited by Jammer

##### Share on other sites

Hope some1 is smart enought to do this...

<{POST_SNAPBACK}>

Aha a challenge.... ```Global \$File = "f.ini"
Global \$line = 2         ;The line which should be deleted....
;
Global \$i_Counter = 0    ;Input Counter
Global \$o_Counter = 0    ;Output Counter
;
While 1
\$i_Counter = \$i_Counter + 1
\$tmpVal = IniRead(\$File, "a", "a" & \$i_Counter, "")
;
If \$tmpVal = "" Then ExitLoop
;
If \$i_Counter <> \$line Then
\$o_Counter = \$o_Counter + 1
IniWrite(\$File, "a", "a" & \$o_Counter, \$tmpVal)
EndIf
WEnd
;remove last input record
If \$i_Counter >  \$line then IniDelete(\$File, "a", "a" & \$i_Counter - 1)```

Live for the present,
Dream of the future,
Learn from the past. ##### Share on other sites

tyvm - thank you very much...

ur genius ## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...