Tsongkie Posted October 12, 2008 Share Posted October 12, 2008 $DATA = "" $NUM = _GUICtrlListBox_GetCount($List1)-1 For $INDEX = 0 To $NUM $DATA &= _GUICtrlListBox_GetText($List1,$INDEX) & @CRLF Next $bboy= FileOpen("bin\bboy.txt",2) FileWrite($bboy,$DATA) FileClose($bboy) What's wrong with this? It doesn't open a file nor create a file.. Link to comment Share on other sites More sharing options...
Mattraks Posted October 12, 2008 Share Posted October 12, 2008 You have to use the full dir. try @ScriptDir & "bin\bboy.txt" and 1 for the mode of FileOpen Link to comment Share on other sites More sharing options...
ResNullius Posted October 12, 2008 Share Posted October 12, 2008 (edited) Does the sub directory "bin" already exist?Edit: @Mattraks,you don't need to specify the full path. And mode 1 is only required if you want to append the output to the file. Edited October 12, 2008 by ResNullius Link to comment Share on other sites More sharing options...
Tsongkie Posted October 12, 2008 Author Share Posted October 12, 2008 yes the bin directory exists.. Link to comment Share on other sites More sharing options...
ResNullius Posted October 12, 2008 Share Posted October 12, 2008 (edited) yes the bin directory exists..Can you post more (or a workable sample) of your script so we can test to see if we get the same results.Also, what OS are you running on, and what directory is the script running in? Edited October 12, 2008 by ResNullius Link to comment Share on other sites More sharing options...
Tsongkie Posted October 12, 2008 Author Share Posted October 12, 2008 Case $Button1 $addfile = FileOpenDialog("Add A File","","All (*.*)") if $addfile <> 1 Then _GUICtrlListBox_AddString ($List1,$addfile) EndIf Case $Button2 $DATA = "" $NUM = _GUICtrlListBox_GetCount($List1)-1 For $INDEX = 0 To $NUM $DATA &= _GUICtrlListBox_GetText($List1,$INDEX) & @CRLF Next $bboy= FileOpen("bin\bboy.txt",2) FileWrite($bboy,$DATA) FileClose($bboy) That's just it.. Link to comment Share on other sites More sharing options...
ResNullius Posted October 12, 2008 Share Posted October 12, 2008 (edited) Case $Button1 $addfile = FileOpenDialog("Add A File","","All (*.*)") if $addfile <> 1 Then _GUICtrlListBox_AddString ($List1,$addfile) EndIf Case $Button2 $DATA = "" $NUM = _GUICtrlListBox_GetCount($List1)-1 For $INDEX = 0 To $NUM $DATA &= _GUICtrlListBox_GetText($List1,$INDEX) & @CRLF Next $bboy= FileOpen("bin\bboy.txt",2) FileWrite($bboy,$DATA) FileClose($bboy) That's just it.. The problem is with the behaviour of FileOpenDialog(). From the "Remarks" section of that command in the helpfile: @WorkingDir is changed on successful return.Insert this line:MsgBox(0,"","ScriptDir is: " & @ScriptDir & @crlf & "WorkingDir is: " & @WorkingDir) before$bboy= FileOpen("bin\bboy.txt",2) and you'll see what the problem is: bboy.txt is attempting to be opened in the WorkingDir, which changes after you add a file to the list. So in that sense, Mattraks was right: add @SciptDir to your FileOpen() command. $bboy = FileOpen("@ScriptDir & "\bin\bboy.txt",2) Edited October 12, 2008 by ResNullius Link to comment Share on other sites More sharing options...
ProgAndy Posted October 12, 2008 Share Posted October 12, 2008 Just save the working Dir and set it back afterwards $__OLD_WORKING_DIR = @WorkingDir $addfile = FileOpenDialog("Add A File","","All (*.*)") FileChangeDir($__OLD_WORKING_DIR) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes 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