afsar 0 Posted September 2, 2005 hi, i want to write in a text file which erases previous contents and writes new line everytime.. i opend the file with fileopen($file,2) ( erase prevoius contents mode) when i use filewrite or filewriteline it is appending to that.. thanx Afsar Share this post Link to post Share on other sites
MHz 75 Posted September 2, 2005 Are you using the filehandle return by FileOpen within the FileWrite function? Share this post Link to post Share on other sites
afsar 0 Posted September 2, 2005 Are you using the filehandle return by FileOpen within the FileWrite function?<{POST_SNAPBACK}>actually my problem is $fi = fileopen($file,2)filewrite($fi,"1st line")filewrite($fi,"2nd line")and my final output is:2nd line.. this i want Share this post Link to post Share on other sites
MHz 75 Posted September 2, 2005 Here is a simple User Defined Function which should do as what you want? Add this function to you script, normally at the bottom. Func _Write($file, $line) Local $handle = FileOpen($file, 2) If $handle <> -1 Then FileWrite($handle, $line) FileClose($handle) EndIf EndFunc Then in that script, just call the function with the parameters filled in like: _Write('C:\file.txt', 'Text is put here') Share this post Link to post Share on other sites
afsar 0 Posted September 7, 2005 Here is a simple User Defined Function which should do as what you want?Add this function to you script, normally at the bottom.Func _Write($file, $line) Local $handle = FileOpen($file, 2) If $handle <> -1 Then FileWrite($handle, $line) FileClose($handle) EndIf EndFuncThen in that script, just call the function with the parameters filled in like:_Write('C:\file.txt', 'Text is put here')<{POST_SNAPBACK}>thanx works perfect.......Afsar Share this post Link to post Share on other sites