Page 1 of 1
[Implemented] WritePreference() should be without spaces
Posted: Fri May 11, 2007 4:17 pm
by eJan
I have problems when I have tried to modify Maxthon 'config.ini' where Version should be writen without spaces like in all other .ini files.
Code: Select all
[Settings]
Language=English
language_file=
Version=1.5.9
But PB write only like. When program read its .ini file it fails. Actualy not a bug.
Code: Select all
[Settings]
Language = English
language_file =
Version = 1.5.9
My replacement to modify config.ini without spaces:
Code: Select all
OpenFile(0, path + "\Config\config.ini")
While Eof(0) = 0
loc = Loc(0)
fnd_string.s = ReadString(0)
If Left(fnd_string, 8) = "Version="
FileSeek(0, loc)
WriteStringN(0, "Version=" + short_ver)
Break
EndIf
Wend
CloseFile(0)
Posted: Fri May 11, 2007 5:41 pm
by AND51
I'd also appreciate it, if this works without spaces... IMHO this was requested several times before...
Posted: Sat May 12, 2007 7:18 am
by horst
AND51 wrote:I'd also appreciate it, if this works without spaces... IMHO this was requested several times before...
... and it should make an empty line after each section.. it's a widespread custom.
Posted: Sat May 12, 2007 8:51 am
by maw
This can be easily done with WinAPI! See my post in this thread:
http://www.purebasic.fr/english/viewtopic.php?t=27023
Basically to write a value all you need is this:
Code: Select all
WritePrivateProfileString_(@"Section", @"Key", @"Value", @"ini-file.ini")
Posted: Sat May 12, 2007 1:49 pm
by AND51
horst wrote:AND51 wrote:I'd also appreciate it, if this works without spaces... IMHO this was requested several times before...
... and it should make an empty line after each section.. it's a widespread custom.
Actually, your're right. But removing the spaces is more important at the moment!
> This can be easily done with WinAPI
Haha, but this is not Linux compatible; IMHO the PB Team tries to only implement new features that are useful for all platforms.
Posted: Sat May 12, 2007 2:00 pm
by ts-soft
AND51 wrote:> This can be easily done with WinAPI
Haha, but this is not Linux compatible; IMHO the PB Team tries to only implement new features that are useful for all platforms.
INI != Prefs
INI only on windows available and easy to use with API
pref a linux compatible without problems, what is the problem. Write INI with
the right function, not with the preference-lib
With spaces looks better than without
Posted: Sat May 12, 2007 2:23 pm
by maw
AND51 wrote:Haha, but this is not Linux compatible; IMHO the PB Team tries to only implement new features that are useful for all platforms.
Not sure what you found so funny, perhaps your sence of humour is a bit warped? :roll:
I was replying to the author of this thread. His question was about modifying an ini-file for Maxthon, which is a Windows program. And it could be solved with a one line of code. What's the problem?
Posted: Sat May 12, 2007 2:45 pm
by AND51
> With spaces looks better than without
It does not have anything to do with its looking, but with compatibility with non-PB programs.
@ maw:
Sorry, then I misunderstood you. I thought you were responding to the whole thread (me inclusive).
Posted: Sat May 12, 2007 3:13 pm
by eJan
Thanks to all!
I didn't know for API function:
http://msdn2.microsoft.com/en-us/library/ms725501.aspx
Going to use API until PB Win problem has been corrected?.
Posted: Sat May 12, 2007 4:02 pm
by maw
eJan wrote:Going to use API until PB Win problem has been corrected?.
It's not a problem/bug that needs correcting. It's doing exactly what it's supposed to do. Though some will argue with Fred whether it is the right way to do it. Me being one of them

But I think there are far more important things to implement so I simply get around these little things any way I can.
Posted: Sat May 12, 2007 7:16 pm
by horst
Has anyone tested the performance of WritePrivateProfileString_() on USB flash drives? It may take several seconds to write a small INI file (just tested with a 128 Mb FAT32 flash drive).
After users complained that one of my programs took 10 seconds to close on a flash drive, I abandoned the M$ functions.
Re: WritePreference() should be without spaces ' = ' <> '=
Posted: Sat Feb 19, 2011 4:50 pm
by Michael Vogel
Spaces are still here, I know
But I didn't know, that also an empty line will be done when doing this...
Code: Select all
OpenPreferences("Reader.ini")
PreferenceGroup("Reader")
For i=0 To 5
WritePreferenceInteger(StringField("Case.Match.Time.Path.Show.Hide",i+1,"."),i)
Next i
ClosePreferences()
Re: WritePreference() should be without spaces ' = ' <> '=
Posted: Sat Feb 19, 2011 5:40 pm
by moogle
I asked too but no changes
http://www.purebasic.fr/english/viewtop ... =3&t=31617
anyway since I just saw this thread I posted some code that you might be able to use here
http://www.purebasic.fr/english/viewtop ... 12&t=45532