Jump to content

Recommended Posts

Posted

Sorry if this was asked before but ...

The way AutoIT writes ini files the entries looks like "key=1" so there are no white spaces between "key" "=" and "1".

There is a simple way to get this done so the ini content could look like "key = 1" (having spaces between)?

I'm asking this because I can't write the ini file of a TFTP server (3CDaemon) - I can write into it but what I can add there it looks like different keys (the difference being those extra white spaces) so the program won't do anything about the keys I try to add.

I could imagine a way implying some text manipulations (read content and insert characters at certain positions ... ) but this is a complicated way. This is the reason to ask for help.

If someone knows a simple way that will be wonderful. If there is no "easy way" - I'll do it.

Thanks anyway for any reply.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Posted

The easiest way is:

$testFile = FileOpen("test.ini", 2)
    $string = FileRead($testFile, FileGetSize("test.ini"));read the file
FileClose($testFile)

$string = StringReplace($string, "=", " = ");replace "=" with " = "

$testFile = FileOpen("test.ini", 2)
    FileWrite($testFile, $string);overwrite to file
FileClose($testFile)

That will work, assuming that there are no "=" within the actual values. Otherwise I'd read the file line by line and use StringinStr to find the first "=" in the line and then to pop in the spaces there.

"Everything is vague to a degree you do not realize till you have tried to make it precise." - Bertrand Russell [The Philosophy of Logical Atomism]

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...