commenti Posted July 31, 2005 Share Posted July 31, 2005 Hello! I have a problem with my Gui which uses a filerequester. If I try to save the value I get from the filerequester in an .ini File it won´t save. To test my problem you need a file called test.ini in the diretory which conains the script. test.ini comes first: [common] testpath=c:\test.txt and here is the AutoIt code. expandcollapse popup#include <GUIConstants.au3> $daten = IniRead("test.ini", "common", "testpath", "") GUICreate("My GUI Test-Tab") ; will create a dialog box that when displayed is centered GUISetBkColor(0x00E0FFFF) GUISetFont(9, 300) $tab = GUICtrlCreateTab(10, 10, 380, 200) $tab0 = GUICtrlCreateTabItem("tab0") GUICtrlSetState(-1, $GUI_SHOW) GUICtrlCreateLabel( "Test", 10, 32, 380, 200, 0x1000) GUICtrlSetBkColor(-1, 0xffffff) $tab1 = GUICtrlCreateTabItem("tab1") GUICtrlCreateLabel("Data", 20, 150, 40, 20) $datapath = GUICtrlCreateInput($daten, 80, 150, 180, 20) $datapathbutton = GUICtrlCreateButton("a", 60, 150, 20, 20) GUICtrlCreateTabItem(""); end tabitem definition GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $datapathbutton Then $datei = FileOpenDialog("Please choose a file.", "", "(*.*)") GUICtrlSetData($datapath, $datei) EndIf If $msg = $GUI_EVENT_CLOSE Then $datei = GUICtrlRead($datapath) MsgBox(0, "This should be written:", $datei) IniWrite("test.ini", "common", "testpath", $datei) ExitLoop EndIf WEnd If you run this script the following happens: In tab1 you have an inputbox, if you write some text there and then close the gui the text is written to the .ini file. If you use the button in the left side, you get a filerequester where you can choose any file. If you chose a file now, the inputbox will be updatet with the path of the file you have chosen. If you now close the gui this path will not be written to .ini file. The message box before the writing of the INI shows the correct value that I wan´t to write to the .ini file. Thats not working and I don´t know why. I really can´t find the bug. Any help anybody? Greetings... commenti. Link to comment Share on other sites More sharing options...
HardCopy Posted July 31, 2005 Share Posted July 31, 2005 (edited) Hello!I have a problem with my Gui which uses a filerequester. If I try to save the value I get from the filerequester in an .ini File it won´t save. To test my problem you need a file called test.ini in the diretory which conains the script. test.ini comes first: [common] testpath=c:\test.txtand here is the AutoIt code.expandcollapse popup#include <GUIConstants.au3> $daten = IniRead("test.ini", "common", "testpath", "") GUICreate("My GUI Test-Tab"); will create a dialog box that when displayed is centered GUISetBkColor(0x00E0FFFF) GUISetFont(9, 300) $tab = GUICtrlCreateTab(10, 10, 380, 200) $tab0 = GUICtrlCreateTabItem("tab0") GUICtrlSetState(-1, $GUI_SHOW) GUICtrlCreateLabel( "Test", 10, 32, 380, 200, 0x1000) GUICtrlSetBkColor(-1, 0xffffff) $tab1 = GUICtrlCreateTabItem("tab1") GUICtrlCreateLabel("Data", 20, 150, 40, 20) $datapath = GUICtrlCreateInput($daten, 80, 150, 180, 20) $datapathbutton = GUICtrlCreateButton("a", 60, 150, 20, 20) GUICtrlCreateTabItem(""); end tabitem definition GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $datapathbutton Then $datei = FileOpenDialog("Please choose a file.", "", "(*.*)") GUICtrlSetData($datapath, $datei) EndIf If $msg = $GUI_EVENT_CLOSE Then $datei = GUICtrlRead($datapath) MsgBox(0, "This should be written:", $datei) IniWrite("test.ini", "common", "testpath", $datei) ExitLoop EndIf WEndIf you run this script the following happens:In tab1 you have an inputbox, if you write some text there and then close the gui the text is written to the .ini file. If you use the button in the left side, you get a filerequester where you can choose any file. If you chose a file now, the inputbox will be updatet with the path of the file you have chosen. If you now close the gui this path will not be written to .ini file. The message box before the writing of the INI shows the correct value that I wan´t to write to the .ini file. Thats not working and I don´t know why. I really can´t find the bug. Any help anybody?Greetings...commenti.<{POST_SNAPBACK}>EDITprefix the path "C:\" or whateverpath u want it , to both the iniread and iniwrite and it will work fine.Hardcopy Edited July 31, 2005 by HardCopy Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad Link to comment Share on other sites More sharing options...
commenti Posted August 1, 2005 Author Share Posted August 1, 2005 EDITprefix the path "C:\" or whateverpath u want it , to both the iniread and iniwrite and it will work fine.Hardcopy<{POST_SNAPBACK}>Hello Hardcopy, thank you for the tip. It worked. I still don´t know why it has to be like that but, it works. What I wanted was that one: IniWrite(@ScriptDir & "\test.ini", "common", "testpath", $datei) -------------I´ll now prefix all my ini writes with that.Thanx again.Greetings Rockford Link to comment Share on other sites More sharing options...
HardCopy Posted August 1, 2005 Share Posted August 1, 2005 Hello Hardcopy, thank you for the tip. It worked. I still don´t know why it has to be like that but, it works. What I wanted was that one: IniWrite(@ScriptDir & "\test.ini", "common", "testpath", $datei) -------------I´ll now prefix all my ini writes with that.Thanx again.Greetings Rockford<{POST_SNAPBACK}>Ah the @scriptDir was missing from your original posted code. I though you had missed declaring a path altogether.I tested with @scriptDir prefixed in both iniread and iniwrite and it works ok to.maybe you forgot to include in both places. Try itHardcopy Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad Link to comment Share on other sites More sharing options...
commenti Posted August 1, 2005 Author Share Posted August 1, 2005 Ah the @scriptDir was missing from your original posted code. I though you had missed declaring a path altogether.I tested with @scriptDir prefixed in both iniread and iniwrite and it works ok to.maybe you forgot to include in both places. Try itHardcopy<{POST_SNAPBACK}>You are right, I did not declare a path. The @scriptDir was missing because I thought it was obsolte. Thats is because only the filerequester value was not saved but all other values were saved without using @scriptDir. This is what I don´t know why it is like that. However, with prefixing @scriptDir everything works fine.Thanx again, grettings... commenti. 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