Kivin Posted January 29, 2007 Share Posted January 29, 2007 Hi everyone! There is my script: expandcollapse popup#include <GUIConstants.au3> If Not FileExists ( "..\Settings.ini" ) Then FileWrite ( "..\Settings.ini" , "" ) IniWrite ( "..\Settings.ini" , "Path", "DestinationPath" , @DesktopDir ) IniWrite ( "..\Settings.ini" , "Path", "SourcePath" , @DesktopDir ) EndIf $DestinationPath = IniRead ("..\Settings.ini" , "Path", "DestinationPath" , "" ) $SourcePath = IniRead ("..\Settings.ini" , "Path", "SourcePath" , "" ) $MainWindow = GUICreate ("Title window" , 600,160) GUISetState (@SW_SHOW) $SourceLabel = GUICtrlCreateLabel ( "Source:" , 10, 10) $SourceInput = GUICtrlCreateInput ( $SourcePath , 100, 8,400, 20) $SourceBrowseButton = GUICtrlCreateButton ( "Browse" , 510, 6, 70, 25) $DestinationLabel = GUICtrlCreateLabel ( "Destination:" , 10, 50) $DestinationInput = GUICtrlCreateInput ( $DestinationPath , 100, 48,400, 20) $DestinationBrowseButton = GUICtrlCreateButton ( "Browse" , 510, 46, 70, 25) $ExitButton = GUICtrlCreateButton ( "Exit" , 510,126, 70, 25) Func BrowseFile () $TempVariable = FileOpenDialog ( "Choose playlist", $SourcePath , "All files (*.*)",1) If Not @error Then GUICtrlSetData ( $SourceInput, $TempVariable ) ;~ MsgBox (0,"",$TempVariable); I try this line to find my error IniWrite ( "..\Settings.ini" , "Path", "SourcePath" , $TempVariable); here is my problem line EndIf EndFunc Func BrowseFolder () $TempVariable = FileSelectFolder( "Choose Destination", "",2 ) If Not @error Then GUICtrlSetData ( $DestinationInput, $TempVariable ) IniWrite ( "..\Settings.ini" , "Path", "DestinationPath" , $TempVariable) EndIf EndFunc Do $msg = GUIGetMsg ( 1 ) Select Case $msg[0] = $SourceBrowseButton BrowseFile () Case $msg[0] = $DestinationBrowseButton BrowseFolder () EndSelect Until $msg[0] = $GUI_EVENT_CLOSE Or $msg[0] = $ExitButton Main function is remember last chosen path to Source file & to Destination folder after pushing browse button & show it after restarting program. Func BrowseFolder work perfect! But Func BrowseFile There is some problem! P.S. If change Settings.ini file path (replace all "..\Settings.ini" with @ScriptDir & "\Settings.ini") everything work perfect! Where is my error? Link to comment Share on other sites More sharing options...
The Kandie Man Posted January 29, 2007 Share Posted January 29, 2007 (edited) Here, this worked for me: expandcollapse popup#include <GUIConstants.au3> If Not FileExists ( @ScriptDir & "\..\Settings.ini" ) Then ;FileWrite ( "..\Settings.ini" , "" ) You don't need this IniWrite (@ScriptDir & "\..\Settings.ini", "Path", "DestinationPath", @DesktopDir ) IniWrite (@ScriptDir & "\..\Settings.ini" , "Path", "SourcePath", @DesktopDir ) EndIf $DestinationPath = IniRead ("..\Settings.ini" , "Path", "DestinationPath" , "" ) $SourcePath = IniRead ("..\Settings.ini" , "Path", "SourcePath" , "" ) $MainWindow = GUICreate ("Title window" , 600,160) GUISetState (@SW_SHOW) $SourceLabel = GUICtrlCreateLabel ( "Source:" , 10, 10) $SourceInput = GUICtrlCreateInput ( $SourcePath , 100, 8,400, 20) $SourceBrowseButton = GUICtrlCreateButton ( "Browse" , 510, 6, 70, 25) $DestinationLabel = GUICtrlCreateLabel ( "Destination:" , 10, 50) $DestinationInput = GUICtrlCreateInput ( $DestinationPath , 100, 48,400, 20) $DestinationBrowseButton = GUICtrlCreateButton ( "Browse" , 510, 46, 70, 25) $ExitButton = GUICtrlCreateButton ( "Exit" , 510,126, 70, 25) Func BrowseFile () $TempVariable = FileOpenDialog ( "Choose playlist", $SourcePath , "All files (*.*)",1) If Not @error Then GUICtrlSetData ( $SourceInput, $TempVariable ) ;MsgBox (0,"",$TempVariable); I try this line to find my error ConsoleWrite(IniWrite ( @ScriptDir & "\..\Settings.ini" , "Path", "SourcePath", $TempVariable)); here is my problem line EndIf EndFunc Func BrowseFolder () $TempVariable = FileSelectFolder( "Choose Destination", "",2 ) If Not @error Then GUICtrlSetData ( $DestinationInput, $TempVariable ) IniWrite( @ScriptDir & "\..\Settings.ini" , "Path", "DestinationPath", $TempVariable) EndIf EndFunc Do $msg = GUIGetMsg ( 1 ) Select Case $msg[0] = $SourceBrowseButton BrowseFile () Case $msg[0] = $DestinationBrowseButton BrowseFolder () EndSelect Until $msg[0] = $GUI_EVENT_CLOSE Or $msg[0] = $ExitButton EDIT Fixed the ones at the top too Edited January 29, 2007 by The Kandie Man "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
sandyd Posted January 29, 2007 Share Posted January 29, 2007 Just a thought, but have you tried using another directory instead of @DesktopDir? ----[ SandyD ]--- Link to comment Share on other sites More sharing options...
/dev/null Posted January 29, 2007 Share Posted January 29, 2007 Hi everyone!There is my script:P.S. If change Settings.ini file path (replace all "..\Settings.ini" with @ScriptDir & "\Settings.ini") everything work perfect!Where is my error?FileOpenDialog() changes the working dir (see help file), so your path "..\Settings.ini" might not make sense after calling that function. NEVERuse relative paths (..\xyz), ALWAYS use absolut paths (@ScriptDir\Settings.ini). __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Chinasmoker Posted January 29, 2007 Share Posted January 29, 2007 FileOpenDialog() changes the working dir (see help file), so your path "..\Settings.ini" might not make sense after calling that function. NEVERuse relative paths (..\xyz), ALWAYS use absolut paths (@ScriptDir\Settings.ini).(@ScriptDir\Settings.ini) = or <> (@ScriptDir & "\Settings.ini") ????Thanks One is never too old to learn Link to comment Share on other sites More sharing options...
/dev/null Posted January 29, 2007 Share Posted January 29, 2007 (@ScriptDir\Settings.ini) = or <> (@ScriptDir & "\Settings.ini") ????Thankswell, the correct AU3 syntax is obviously: @ScriptDir & "\Settings.ini". I was just giving an example.... __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Chinasmoker Posted January 29, 2007 Share Posted January 29, 2007 well, the correct AU3 syntax is obviously: @ScriptDir & "\Settings.ini". I was just giving an example....I see ,Thanks any way One is never too old to learn Link to comment Share on other sites More sharing options...
Kivin Posted January 29, 2007 Author Share Posted January 29, 2007 Thanks all of you for help. I understand my error. 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