textFiles

nick2210

Member
Hello.
Can anybody tell me how to use one button for writing to a *.txt file and another button for reading from the same file.

Sub btnRead_click
FileOpen(c1,"txt.txt",cRead)
s=FileRead(c1)
label1.text=s
FileClose(c1)
End Sub

........reads the first line of the "txt.txt",when the button is clicked second time an error message shows.
If I place the FileOpen line in "Sub App_Start" the file is read well,but how do I open a cWrite connection then?

P.S. I have failed to get a clue in the Erel's TextFiles tutorial.:sign0085:
 

mjcoon

Well-Known Member
Licensed User
I have commented elsewhere in the forum that because the Help mentions "write-only" files the reader could think that reading and writing are mutually exclusive.

But I'm sure that you'll find that if you open the file for writing (just once) you will be able to read from it as well.

But you have to consider what it means to read and write to the same file. It can be OK if done at random using a byte index from the front of the file to define what is happening. (The file is then just like a byte array.) But this may be incompatible with the simple view that each time a read takes place there is an implicit pointer that moves forward to ensure that the same line of text is not read again. (And similarly for appending.)

You have not told us exactly what effect you are trying to produce...

Mike.
 

nick2210

Member
thanx a bundle Mike.
I am trying to produce an effect of reading from *.txt file at btnRead_click.When the user wishes to write to that *.txt file,he just clicks the "Write" button and writes a string from a textbox.
I think i have found a proper thread in the forum.This effect can be reached using a table control :)
 

nick2210

Member
Hello Mike.
Hello everybody.
Here's the effect I was trying to produce.I'm sure it is going to be very useful for my future applications.
I also think some beginner like myself may find it useful.
 

Attachments

  • TextFiles.zip
    801 bytes · Views: 183
Top