AZJIO Posted January 9, 2014 Share Posted January 9, 2014 (edited) 1. If I write 200 values, the ini-file will be overwritten 200 times. This is not economical. #include <GUIConstantsEx.au3> ; Свой реестр $Ini = @ScriptDir & '\prog.ini' $ifTrChMax = Number(IniRead($Ini, 'Setting', 'Max', '0')) $hGui = GUICreate('My Program', 250, 260) $iChMax = GUICtrlCreateCheckbox("Checkbox 1", 10, 10, 120, 20) If $ifTrChMax Then GUICtrlSetState(-1, $GUI_CHECKED) GUISetState() While 1 Switch GUIGetMsg() Case $iChMax $ifTrChMax = _ChReadToBool($iChMax) Case -3 GUIDelete($hGui) _Exit() EndSwitch WEnd Func _ChReadToBool($iID) If BitAND(GUICtrlRead($iID), $GUI_CHECKED) Then Return 1 Else Return 0 EndIf EndFunc ;==>_ChReadToBool Func _Exit() IniWrite($Ini, "Setting", "Max", $ifTrChMax) Exit EndFunc ;==>_Exit 2. If duplicate 2 status and check the difference, the number of entries will depend on the modified flags. #include <GUIConstantsEx.au3> ; Свой реестр $Ini = @ScriptDir & '\prog.ini' $ifTrChMax = 0 $iniMax = Number(IniRead($Ini, 'Setting', 'Max', '0')) $ifTrChMax = $iniMax $hGui = GUICreate('My Program', 250, 260) $iChMax = GUICtrlCreateCheckbox("Checkbox 1", 10, 10, 120, 20) If $ifTrChMax Then GUICtrlSetState(-1, $GUI_CHECKED) GUISetState() While 1 Switch GUIGetMsg() Case $iChMax $ifTrChMax = _ChReadToBool($iChMax) Case -3 GUIDelete($hGui) _Exit() EndSwitch WEnd Func _ChReadToBool($iID) If BitAND(GUICtrlRead($iID), $GUI_CHECKED) Then Return 1 Else Return 0 EndIf EndFunc ;==>_ChReadToBool Func _Exit() ; Если изменилось с момента чтения ini-файла, то записать новое значение If $ifTrChMax <> $iniMax Then IniWrite($Ini, "Setting", "Max", $ifTrChMax) Exit EndFunc ;==>_Exit 3. If before exiting the program to read the ini-file into an array and make the upgrade in memory, the overwritten will be executed one time. (>IniVirtual.au3) expandcollapse popup#include <GUIConstantsEx.au3> #include <IniVirtual.au3> ; Свой реестр $Ini = @ScriptDir & '\prog.ini' $ifTrChMax = Number(IniRead($Ini, 'Setting', 'Max', '0')) $hGui = GUICreate('My Program', 250, 260) $iChMax = GUICtrlCreateCheckbox("Checkbox 1", 10, 10, 120, 20) If $ifTrChMax Then GUICtrlSetState(-1, $GUI_CHECKED) GUISetState() While 1 Switch GUIGetMsg() Case $iChMax $ifTrChMax = _ChReadToBool($iChMax) Case -3 GUIDelete($hGui) _Exit() EndSwitch WEnd Func _ChReadToBool($iID) If BitAND(GUICtrlRead($iID), $GUI_CHECKED) Then Return 1 Else Return 0 EndIf EndFunc ;==>_ChReadToBool Func _Exit() Local $a_ini_Main2D, $hFile, $s_ini_Text $s_ini_Text = FileRead($Ini) $a_ini_Main2D = _IniVirtual_Initial($s_ini_Text) _IniVirtual_Write($a_ini_Main2D, 'Setting', 'Max', $ifTrChMax) $s_ini_Text = _IniVirtual_Save($a_ini_Main2D) $hFile = FileOpen($Ini, 2) FileWrite($hFile, $s_ini_Text) FileClose($hFile) Exit EndFunc ;==>_Exit I chose the last option. There are other opinions? I know that the registry is better, but I'm taking into account the transfer on a flash drive. Edited January 9, 2014 by AZJIO My other projects or all Link to comment Share on other sites More sharing options...
Gianni Posted January 9, 2014 Share Posted January 9, 2014 maybe IniWriteSection could be more appropriate instead of IniWrite Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
AZJIO Posted January 9, 2014 Author Share Posted January 9, 2014 He writes with one stream? Maybe I should not bother. (1000 launch) * (20-40 parameters) = (20 000 rewrite) 5 KB * 20 000 = 100 MB Some programs can only be configured when you first start. Or 10 starts, one of them an rewrite in the ini-file. I want to decide on the choice of algorithm, then not to remake. My other projects or all Link to comment Share on other sites More sharing options...
Zedna Posted January 9, 2014 Share Posted January 9, 2014 (edited) I use option 2) in my bigger projects. Edited January 9, 2014 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
AutID Posted January 10, 2014 Share Posted January 10, 2014 Option 2 https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
Morthawt Posted January 10, 2014 Share Posted January 10, 2014 Why not manually create the ini in the form of an array or variable and then transfer that to a file directly? You can still use a normal iniread but at least the write would be a single process to transform the variable to saved file. Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
Gianni Posted January 10, 2014 Share Posted January 10, 2014 (edited) I think AZJIO want to use that in an intensive concurrent read / write environment where many instances of that task will run on the same ini. (or not?.... in that form all tasks access the same key within the ini) ... in that case I also would take in consideration the use of SQLite as in >this jchd's example for intensive concurrent r/w acces to a database Edited January 10, 2014 by PincoPanco Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
DXRW4E Posted January 10, 2014 Share Posted January 10, 2014 (edited) >INI File Processing Functions work for real by reference, has not the speed of AutoIt INI Function, but it is quite fast and has no limits and more options Ciao. Edited January 10, 2014 by DXRW4E Link to comment Share on other sites More sharing options...
AZJIO Posted January 10, 2014 Author Share Posted January 10, 2014 SSD Write Limit @Morthawt See item 3. This is what you're saying. @PincoPanco No. I just do not want to write something that does not require writing. Ideal logic to do only what is required. Flash card slower and worn more out. My other projects or all Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now