Aliende Posted October 4, 2005 Share Posted October 4, 2005 Hi there! I've got a pretty annoying problem with the IniWrite() function: It does write crap. I'm doing a script which is restoring Ghost Images in my company - and the script should store the paths for the image files. But whatever I let it write - it just writes crap. Numeric crap. And by the way: The IniRead() function oly works sometimes, and only with the $Win2k_path var. Here's the code of the GUI-Window and subroutines which handle that (this code won't run standalone of course : expandcollapse popupFunc ConfigWindow() $configwindow = GUICreate ("Konfiguration", 500, 300, -1, -1, $WS_EX_ACCEPTFILES) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $configokbutton = GUICtrlCreateButton("OK", 30, 120, 100) GUICtrlSetOnEvent($configokbutton, "ConfigOk") GUICtrlSetState(-1,$GUI_FOCUS) $configcancelbutton = GUICtrlCreateButton("Abbrechen", 140, 120, 100) GUICtrlSetOnEvent($configcancelbutton, "CLOSEClicked");TODO: Link with ChildClose $configsavebutton = GUICtrlCreateButton("Speichern", 250, 120, 100) GUICtrlSetOnEvent($configsavebutton, "IniWriter") $configundobutton = GUICtrlCreateButton("Verwerfen", 360, 120, 100) GUICtrlSetOnEvent($configundobutton, "Undo") GUISetState (@SW_SHOW) GUICtrlCreateLabel("Pfad für Windows XP-Image:", 30, 15); Path input $WinXP_path = GUICtrlCreateInput ("", 200, 10, 270) GUICtrlSetState(-1,$GUI_ACCEPTFILES) GUICtrlCreateLabel("Pfad für Windows 2000-Image:", 30, 50) $Win2k_path = GUICtrlCreateInput ("", 200, 45, 270) GUICtrlSetState(-1,$GUI_ACCEPTFILES) GUICtrlCreateLabel("Pfad für Windows 2003-Image:", 30, 85) $Win2k3_path = GUICtrlCreateInput ("", 200, 80, 270) GUICtrlSetState(-1,$GUI_ACCEPTFILES) EndFunc ;Out of this funcions crap is born: Func IniReader() $WinXP_path = IniRead (@ScriptDir & "\ImageRestore.ini", "PATHS", "WinXP", "No Entry") $Win2k_path = IniRead (@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k", "No Entry") $Win2k3_path = IniRead (@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k3", "No Entry") EndFunc Func IniWriter() IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "WinXP", $WinXP_path) IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k", $Win2k_path) IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k3", $Win2k3_path) EndFunc I'm so glad if someone can help! Link to comment Share on other sites More sharing options...
jefhal Posted October 4, 2005 Share Posted October 4, 2005 (edited) Func IniReader() $WinXP_path = IniRead (@ScriptDir & "\ImageRestore.ini", "PATHS", "WinXP", "No Entry") $Win2k_path = IniRead (@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k", "No Entry") $Win2k3_path = IniRead (@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k3", "No Entry") EndFunc Func IniWriter() IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "WinXP", $WinXP_path) IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k", $Win2k_path) IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k3", $Win2k3_path) EndFunc I don't see where you actually call these functions in your script? Also, you might want to put some debug msgboxes or tooltip lines inside the functions to see what values you are getting for @ScriptDir before it is concatenating it. Edited October 4, 2005 by jefhal ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Aliende Posted October 4, 2005 Author Share Posted October 4, 2005 Func IniReader() $WinXP_path = IniRead (@ScriptDir & "\ImageRestore.ini", "PATHS", "WinXP", "No Entry") $Win2k_path = IniRead (@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k", "No Entry") $Win2k3_path = IniRead (@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k3", "No Entry") EndFunc Func IniWriter() IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "WinXP", $WinXP_path) IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k", $Win2k_path) IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k3", $Win2k3_path) EndFuncI don't see where you actually call these functions in your script? Also, you might want to put some debug msgboxes or tooltip lines inside the functions to see what values you are getting for @ScriptDir before it is concatenating it.I'm calling the IniWriter() function with the configsavesavebutton (german: save= Speichern): $configsavebutton = GUICtrlCreateButton("Speichern", 250, 120, 100)GUICtrlSetOnEvent($configsavebutton, "IniWriter")The IniRead() function isn't actually called in with this GUI, but in the general script to ensure it is called before the actual call of the configuration window function.I did some MsgBoxes to get the values. Here are the values of the three paths:[PATHS] WinXP=4107 Win2k=4109 Win2k3=4111 Link to comment Share on other sites More sharing options...
GaryFrost Posted October 4, 2005 Share Posted October 4, 2005 CODE Func IniReader() GUICtrlSetData($WinXP_path, IniRead(@ScriptDir & "\ImageRestore.ini", "PATHS", "WinXP", "No Entry")) GUICtrlSetData($Win2k_path, IniRead(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k", "No Entry")) GUICtrlSetData($Win2k3_path, IniRead(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k3", "No Entry")) EndFunc ;==>IniReader Func IniWriter() IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "WinXP", GUICtrlRead($WinXP_path)) IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k", GUICtrlRead($Win2k_path)) IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k3", GUICtrlRead($Win2k3_path)) EndFunc ;==>IniWriter SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Aliende Posted October 4, 2005 Author Share Posted October 4, 2005 CODEFunc IniReader() GUICtrlSetData($WinXP_path, IniRead(@ScriptDir & "\ImageRestore.ini", "PATHS", "WinXP", "No Entry")) GUICtrlSetData($Win2k_path, IniRead(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k", "No Entry")) GUICtrlSetData($Win2k3_path, IniRead(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k3", "No Entry"))EndFunc ;==>IniReaderFunc IniWriter() IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "WinXP", GUICtrlRead($WinXP_path)) IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k", GUICtrlRead($Win2k_path)) IniWrite(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k3", GUICtrlRead($Win2k3_path))EndFunc ;==>IniWriterTHANK YOU! YOU ARE MY PERSONAL HERO! Link to comment Share on other sites More sharing options...
jefhal Posted October 4, 2005 Share Posted October 4, 2005 CODE GUICtrlSetData($WinXP_path, IniRead(@ScriptDir & "\ImageRestore.ini", "PATHS", "WinXP", "No Entry")) GUICtrlSetData($Win2k_path, IniRead(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k", "No Entry")) GUICtrlSetData($Win2k3_path, IniRead(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k3", "No Entry"))gafrost-Can you tell us why the earlier method didn't work? Shouldn't iniread have returned the value? Thanks... ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Developers Jos Posted October 4, 2005 Developers Share Posted October 4, 2005 Can you tell us why the earlier method didn't work? Shouldn't iniread have returned the value? Thanks...$WinXP_path = GUICtrlCreateInput ("", 200, 10, 270)$WinXP_path will contain the Handle to the Input GUIControl. To set the Value of a Control, you do GUICtrlSetData().To retrieve the value a a control you do GuiCtrlRead().So this statement corrupts the Control handle value and doesn't set the control to the value $WinXP_path = IniRead (@ScriptDir & "\ImageRestore.ini", "PATHS", "WinXP", "No Entry") SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jefhal Posted October 4, 2005 Share Posted October 4, 2005 $WinXP_path = IniRead (@ScriptDir & "\ImageRestore.ini", "PATHS", "WinXP", "No Entry")Oh, thanks. And, the line above would return the key value (according to help on IniRead), not a handle? ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Developers Jos Posted October 4, 2005 Developers Share Posted October 4, 2005 Oh, thanks. And, the line above would return the key value (according to help on IniRead), not a handle?Yes you are correct.But i am trying to explain that the variable $WinXP_path already contains the Handle to the GUI control and should not be overridden with the value from the INI. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jefhal Posted October 5, 2005 Share Posted October 5, 2005 Yes you are correct.But i am trying to explain that the variable $WinXP_path already contains the Handle to the GUI control and should not be overridden with the value from the INI.Got it. Thanks JdeB! ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Aliende Posted October 5, 2005 Author Share Posted October 5, 2005 So, one of my problems stays: I'm getting numeric crap out of the IniRead() function. I've attached the complete source file of the script and the ini file. The ini-file is a .txt file since I wasn't allowed to load up a .ini file. So in case you wanna test my script, rename the .txt file to .ini ;-). Here are the instructions to what I wanna show you: If you click "Config" in the main window, the IniRead() function is called and a MsgBox will appear, listing the values of $WinXP_path, $Win2k_path and $Win2k3_path, which are empty (this even happens if values are allready in the ini). After that, the child window should pop up - giving you no values at all. Type something into the input fields and hit "speichern" (which is german for "save"). Now, the ini has been written, and I get the following numbers inserted in the different input fields: WinXp_path: 4107 Win2k_path: 4109 Win2k3_path: 4111 Now here comes the crap: When I press OK or Abbrechen (which is cancel), some weird stuff happens: although the function for the buttons looks like this: Func ChildClose() GUISetState(@SW_HIDE) GUISwitch($mainwindow) GUISetState(@SW_SHOW) EndFunc;==> ChildClose the window won't get hidden and the parent activated. No: the ini gets (PROPERLY!) re-read and the child window (the config dialog) stays forever (or at least until I press escape). If you press save (speichern) now, the numbers become visible again, but doubled. If you hit ok or cancel, the ini gets properly read and display of the values is correct. no here comes even better stuff: start the app anew, press config and click "ok" or "abbrechen" (which actually have the same functions called on mouseclick). Do not press save. Guess what happens? The child gets "closed" (hidden), and the poarent visible... I sat all day on this and it didn't get better. I gotta get home to un-brainf***... I would be very very happy if someone of yould help me again! Link to comment Share on other sites More sharing options...
GaryFrost Posted October 5, 2005 Share Posted October 5, 2005 1: change button event to $configbutton = GuiCtrlCreateButton("Config", 250, 120, 100) GUICtrlSetOnEvent($configbutton, "ConfigWindow") 2:Correct creating input controls CODE Func ConfigWindow() ; Call IniReader for the input fields: ;IniReader() ;IniReader() ; Start Config GUI: $configwindow = GUICreate("Konfiguration",500,300,-1,-1,BitOr($WS_POPUP, $WS_CAPTION),-1,$mainwindow) ;GUISetState(@SW_HIDE) ;GUISwitch($configwindow) ;GUISetState(@SW_SHOW) ;$configwindow = GUICreate ("Konfiguration", 500, 300, -1, -1, $WS_EX_ACCEPTFILES) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $configokbutton = GUICtrlCreateButton("OK", 30, 120, 100) GUICtrlSetOnEvent($configokbutton, "ConfigOk") GUICtrlSetState(-1,$GUI_FOCUS) $configcancelbutton = GUICtrlCreateButton("Abbrechen", 140, 120, 100) GUICtrlSetOnEvent($configcancelbutton, "ChildClose") $configsavebutton = GUICtrlCreateButton("Speichern", 250, 120, 100) GUICtrlSetOnEvent($configsavebutton, "IniWriter") $configundobutton = GUICtrlCreateButton("Verwerfen", 360, 120, 100) GUICtrlSetOnEvent($configundobutton, "Undo") GUICtrlSetState ($configundobutton, $GUI_DISABLE) ;DEAKTIVIERT DEN UNDO-BUTTON GUISetState (@SW_SHOW) GUICtrlCreateLabel("Pfad für Windows XP-Image:", 30, 15) $WinXP_path = GUICtrlCreateInput ("", 200, 10, 270) GUICtrlSetState(-1,$GUI_ACCEPTFILES) GUICtrlCreateLabel("Pfad für Windows 2000-Image:", 30, 50) $Win2k_path = GUICtrlCreateInput ("", 200, 45, 270) GUICtrlSetState(-1,$GUI_ACCEPTFILES) GUICtrlCreateLabel("Pfad für Windows 2003-Image:", 30, 85) $Win2k3_path = GUICtrlCreateInput ("", 200, 80, 270) GUICtrlSetState(-1,$GUI_ACCEPTFILES) IniReader() ; load controls from ini EndFunc ;==>ConfigWindow 3: remove call in inireader CODE Func IniReader() MsgBox(48,"Break","Contents of WinXP, Win2k and Win2k3:", $WinXP_path & $Win2k_path & $Win2k3_path) GUICtrlSetData($WinXP_path, IniRead(@ScriptDir & "\ImageRestore.ini", "PATHS", "WinXP", "No Entry")) GUICtrlSetData($Win2k_path, IniRead(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k", "No Entry")) GUICtrlSetData($Win2k3_path, IniRead(@ScriptDir & "\ImageRestore.ini", "PATHS", "Win2k3", "No Entry")) ;~ ConfigWindow() EndFunc ;==>IniReader SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Aliende Posted October 6, 2005 Author Share Posted October 6, 2005 Thank you very much! I'm pretty sure I once had it that way - except the fact I didn't put the IniReader call after the GUI creation section(I'm sure I onec had, but not with the combination of functions and other code in the rest of the script). What surprises me though, is that now I don't get that numeric crap - and I wonder why. I just don't get it. Could you please explain that to me? Link to comment Share on other sites More sharing options...
GaryFrost Posted October 6, 2005 Share Posted October 6, 2005 Here's where the problem was$WinXP_path = GUICtrlCreateInput ($WinXP_path , 200, 10, 270)$Win2k_path = GUICtrlCreateInput ($Win2k_path , 200, 45, 270)$Win2k3_path = GUICtrlCreateInput ($Win2k3_path , 200, 80, 270)you were displaying the handle then assigning the handle to each control SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Aliende Posted October 11, 2005 Author Share Posted October 11, 2005 I actually thought this is for reading the variable and passing it to the CreateInput function... 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