Jump to content

File write


afsar
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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')
Link to comment
Share on other sites

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')

<{POST_SNAPBACK}>

thanx works perfect.......

Afsar

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...