Bex wrote:ZvezdanD wrote:Bex wrote:Well, you need to use the Flush method to ensure that your changed (or created) ini values are immediately saved to the disk.
I knew that you will say that. Well, I don't need to use the Flush method since my scripts work just fine without it (and without installed your scripts). And it is not true that SDB.IniFile is a way faster if it is used with a global variable. Anyway, I don't need to write to .ini file so often to get some slow-downs because of such use. In my opinion reliability is more important than speed. If I need reliability I need to use Flush method every time after oSomeGlobalIniVarialble.StringValue = ..., so I would get same slow-downs as when I use SDB.IniFile directly. You are not using Flush method either, so if the program crashes your .ini settings made during last session would be lost as well.
Yes, you do need to use the flush method to ensure that your scripts write its ini values to the ini file. No, it is indeed very true that a script is way faster if you use a variable for SDB.IniFile, you can even use it in a loop without any delay.
So instead of calling other scripts nasty, you should change your scripts so they give you the reliability you need if MM crashes.
No, I don't need to use Flush method and my scripts would save values to the .ini file correctly. They are not working correctly only if I have installed your scripts. Yes, your scripts are nasty because I lost several hours of my time writing some SQL queries for Magic Nodes and Regular expressions for Find & Replace script only because I had installed your scripts - if I didn't have your scripts installed it would not happen. Yes, I could add the Flush method to my scripts, but you didn't answer to my question what about a bunch of old scripts where their authors are not supporting them anymore. As I said, this change in .ini handling is most problematic of all MM devs decisions. I am not the only one who is against their decision - I remember many complains of some scripters about it, at least it was MoDementia and raybeau528. I remember many times Jiri responded to me and other scripters when we asked why some things are implemented like they are and he said that he do not want to change anything because of compatibility. On another side, he added such thing like .ini handling and Flush method which affect with compatibility more than we asked for. I remember also some scripters had some errors generated on the line with the Flush method, I think it was raybeau528 with some of his scripts. If you think that the Flush method is a solution, why don't you use it in your scripts?
You could repeat your claims as many times as you want, but you didn't give me any proof. I remember two times before I gave you a proof that my code is faster than your sending you test scripts, and you responded how "even though it is slower (wonder why?) it's still unnoticeable imo since the function is only used a couple of times". So, I could respond like you and repeat myself - I am not using access to .ini file so often to notice such slow-downs. But, you are intentionally skip my main point about this all the time - I am not telling that you should not use variables to access IniFile object, I just say that you should not use GLOBAL variable for such thing. I am using local variables for IniFile object whenever it should and it works nothing more slower than with a global variable. If you are so concerned about the speed why your PlayHistory is not using global variable for IniFile object?
However, instead of you, I have a real proof that you are wrong. Your claim that using a global varibale and the Flush method is a way faster than direct access to the IniFile object is simply opposite to the truth. Here are two test scripts. You need to remove all scripts from Auto folder and to copy the first and the second script in it one at time, i.e. save the first script to Auto folder, start MM program and wait for it to finish, than exit program, delete the fist script, copy the second one to Auto folder and start MM. If you are too lazy to do this, here are results - my version of code is executing for 44 seconds, and your version is executing for 230 seconds! Now, could you tell me whose code is a way faster?
Code: Select all
' Zvezdan's version of the .ini file access
Option Explicit
Sub OnStartUp()
Dim i, j
Dim dTime
dTime = Timer
For j = 1 To 10000
For i = 1 To 9
SDB.IniFile.IntValue("ZvezdanTest", "Item" & i) = Int(Rnd * 100000)
Next
Next
SDB.MessageBox FormatNumber(Timer - dTime, 2), mtInformation, Array(mbOk)
End Sub
Code: Select all
' Bex's version of the .ini file access
Option Explicit
Dim oIniFile
Set oIniFile = SDB.IniFile
Sub OnStartUp()
Dim i, j
Dim dTime
dTime = Timer
For j = 1 To 10000
For i = 1 To 9
oIniFile.IntValue("ZvezdanTest", "Item" & i) = Int(Rnd * 100000)
oIniFile.Flush
Next
Next
SDB.MessageBox FormatNumber(Timer - dTime, 2), mtInformation, Array(mbOk)
End Sub