How To... Set something like cookies for $inputs
#1
Posted 07 November 2009 - 05:04 PM
Simple question
How to remember (by program) text what i was wrote in Inputbox?
Example
I was wrote some text in some program to input box (long text) and i close the program
I dont want write this text again when i open this program again :(
Is there any way to remember what user set in inputs, before he close the program?
#3
Posted 07 November 2009 - 05:13 PM
Sobiech, on 07 November 2009 - 08:04 AM, said:
Simple question
How to remember (by program) text what i was wrote in Inputbox?
Example
I was wrote some text in some program to input box (long text) and i close the program
I dont want write this text again when i open this program again :(
Is there any way to remember what user set in inputs, before he close the program?
See the INI functions in the Help file under Function Reference >> File, Directory and Disk functions Reference
The two you are looking for are IniWrite and IniRead
This post has been edited by GEOSoft: 07 November 2009 - 05:15 PM
#6
Posted 07 November 2009 - 06:06 PM
Dim $Input[11], $Ini_File = False, $File_Location = @ScriptDir & "Input.ini" If FileExists($File_Location) Then $Ini_File = True For $x = 1 To 10 If $Ini_File Then $Input[$x] = IniRead($File_Location, "Input", $x, "") $Input[$x] = InputBox("Input", "Please type in your input", $Input[$x]) IniWrite($File_Location, "Input", $x, $Input[$x]) Next
8)
Fixed IniRead() error, still not tested
This post has been edited by Valuater: 07 November 2009 - 06:09 PM
#7
Posted 07 November 2009 - 06:08 PM
$sIni = @AppDataDir & "\Myapp\Myapp.ini" $Input1 = GUICtrlCreateInput() $Input2 = GUICtrlCreateInput() more more more etc. $input30 = GUICtrlCreateInput() For $i = $Input1 To $Input30 GUICtrlSetData($i, IniRead($sIni, "Settings", $i, "")) Next GUISetState() While 1 $nMsg = GUIGetMsg() Switch $Msg Case -3 For $i = $Input1 To $Input30 If IniRead(IniRead($sIni, "Settings", $i, "") <> GUICtrlRead($i) Then IniWrite($sIni, "Settings", $i, GUICtrlRead($i) EndIf Next Exit EndSwitch Wend
Edit: Corrected closing code tag
This post has been edited by GEOSoft: 07 November 2009 - 06:09 PM
#8
Posted 07 November 2009 - 06:27 PM
$sIni = @AppDataDir & "\Myapp\Myapp.ini" $StartKey = GUICtrlCreateInput() $RunKey = GUICtrlCreateInput() $ExitKey = GUICtrlCreateInput()
Can I use
Dim $startkey[0], $runkey[1] ???
How can i use "for loop" if my inputs have the captions above
#9
Posted 07 November 2009 - 08:34 PM
Dim $startkey[0], $runkey[1] ???
No, this will not work.
How can i use "for loop" if my inputs have the captions above
You will not be able to use a "for loop" with different names
(unless they are in an array, but that is another story and more complicated)
8)
#10
Posted 07 November 2009 - 11:41 PM
GEOSoft, on 07 November 2009 - 06:08 PM, said:
$sIni = @AppDataDir & "\Myapp\Myapp.ini" $Input1 = GUICtrlCreateInput() $Input2 = GUICtrlCreateInput() more more more etc. $input30 = GUICtrlCreateInput() For $i = $Input1 To $Input30 GUICtrlSetData($i, IniRead($sIni, "Settings", $i, "")) Next GUISetState() While 1 $nMsg = GUIGetMsg() Switch $Msg Case -3 For $i = $Input1 To $Input30 If IniRead(IniRead($sIni, "Settings", $i, "") <> GUICtrlRead($i) Then IniWrite($sIni, "Settings", $i, GUICtrlRead($i) EndIf Next Exit EndSwitch Wend
Edit: Corrected closing code tag
I have Syntax error :\
C:\Project\123.au3(278,78) : ERROR: syntax error If IniRead(IniRead($Ini, "Settings", $i, "") <> GUICtrlRead($i) Then ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Project\123.au3(279,64) : ERROR: syntax error IniWrite($Ini, "Settings", $i, GUICtrlRead($i) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
and more more more more in rest od code (but only if i use your code :|)
#11
Posted 07 November 2009 - 11:45 PM
If IniRead(IniRead($sIni, "Settings", $i, "")) <> GUICtrlRead($i) Then IniWrite($sIni, "Settings", $i, GUICtrlRead($i))
You're missing the closing parentheses.
#12
Posted 08 November 2009 - 12:17 AM
Authenticity, on 07 November 2009 - 11:45 PM, said:
If IniRead(IniRead($sIni, "Settings", $i, "")) <> GUICtrlRead($i) Then IniWrite($sIni, "Settings", $i, GUICtrlRead($i))
You're missing the closing parentheses.
C:\Project\123.au3(283,46) : ERROR: IniRead() [built-in] called with wrong number of args. If IniRead(IniRead($Ini, "Settings", $i, "")) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Project\D2NT1.5v3.6M2ConfigEditorByInFlames.au3 - 1 error(s), 0 warning(s) >Exit code: 2 Time: 0.217
O_o
Ahh and i change names of $inputs :)
I have now 61 input fields :)
This post has been edited by Sobiech: 08 November 2009 - 12:19 AM
#13
Posted 08 November 2009 - 12:29 AM
If IniRead($sIni, "Settings", $i, "") <> GUICtrlRead($i) Then IniWrite($sIni, "Settings", $i, GUICtrlRead($i))
This is syntactically correct, it might not be correct though.
#15
Posted 08 November 2009 - 12:53 AM
So I have
For $i = $Input1 To $Input61 GUICtrlSetData($i, IniRead($Ini, "Settings", $i, "")) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3 For $i = $Input1 To $Input61 If IniRead($Ini, "Settings", $i, "") <> GUICtrlRead($i) Then IniWrite($Ini, "Settings", $i, GUICtrlRead($i)) EndIf Next Exit EndSwitch Wend
I think this can help me to load last $inputs from .ini?
And one more thing, actually i dont have .ini from i can load informations. First i must create it :\
I used one time this thing
IniWrite($Ini, "Keys", "StartKey", $input43)
And this is ok, but i have 61 inputs O_o.
Is there faster way to create that ini?
#17
Posted 08 November 2009 - 01:30 AM
#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $INI = "MyINI.ini" $Form1 = GUICreate("Massive over-exaggeration FTW", 800, 600) Dim $Input[85] Dim $InputText[85] For $n = 0 To UBound($InputText)-1 Step 1 $InputText[$n] = IniRead($INI,"Inputs","Input"&$n,"") Next $n = 0 For $x= 8 To 600 Step 130 For $y = 8 To 400 Step 24 $Input[$n] = GUICtrlCreateInput($InputText[$n], $x, $y, 121, 21) $n+=1 Next Next $Save = GUICtrlCreateButton("Save values",8,450,100,100) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $save For $n = 0 To UBound ($Input)-1 Step 1 ToolTip("saving value " & $n) IniWrite($INI,"Inputs","Input"&$n,GUICtrlRead($Input[$n])) Next Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd

Sign In
Register
Help
MultiQuote