Why text1.txt is no change?

Theera

Expert
Licensed User
Longtime User
Hi All,
I re-create a new widget (Attached File too). My problem is Thread 's name. Here you are my source code English version. Please help me to correct them. I use more 3 months ,I cann't make it complete. I'm sorry ,I'm not good at English.

Best Regards
Theera
:sign0085:
 
Last edited:

derez

Expert
Licensed User
Longtime User
I couldn't run your application but I think the problem may be with the use of DirDefaultExternal which is read only
Try to replace it with DirRootExternal.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I didn't have enough time to check the entire code but in the section of adding a new record (btnkeep_click) you should remove the crlf from this IF:
B4X:
If File.Exists(File.DirDefaultExternal,"Text1.txt") Then
                            Dim Writer As TextWriter
                           Writer.Initialize(File.OpenOutput(File.DirDefaultExternal,"Text1.txt",True))
                           Writer.WriteLine(TxtRRName.Text & "," & TxtUUPrice.Text ) 
' a problem was here, in writeLine.
'You used crlf, thus inserting an empty line.
'Thus, when you were reading from this file,
'an error was produced because
'a 'comma' could not be found in this empty line.
                           Writer.Close
                     End If
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
Hi David , mc73 and all,
I have done follow your guide( change DirRootExternal,and removed the CRLF).It still has error occurred.

Best Regards
Theera:eek:
 
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Hi David , mc73 and all,
I have done follow your guide( change DirRootExternal,and removed the CRLF).It still has error occurred.

Best Regards
Theera:eek:
Did you replace your txt file with the old one? If not, surely this error will still occure, since it contains the blank lines. Place a copy of your old file in the directory you prefer, and give it another try :)
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
Replace all text1.txt to text2.txt

Did you replace your txt file with the old one? If not, surely this error will still occure, since it contains the blank lines. Place a copy of your old file in the directory you prefer, and give it another try :)

Hi mc73,
Thank you for kind of you. I 've a new problem. I replace all text1.txt to text2.txt for make sure text2.txt doesn't t cantain the blank lines. It's right,it has no error occurred ,but after I insert a new data and save it,text2.txt is not change,it wil change after re-insert again. Why not my widget ,it save the first time?

p.s. I'm not good at English

Best regards
Theera
:eek:
 
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Your original text.txt file, was not finishing with a carriage return, thus, the first time you begin your app, the new line is not appended as new line, but as a continuation of the last line of your file. You should edit your original text.txt by pressing 'enter' at the end of it, and then save it, before uploading it to your dirroot or dirdefault or whatever folder you choose. One good way to debug such cases is to open your edited file by another editor. This way you can see what went wrong.
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
Your original text.txt file, was not finishing with a carriage return, thus, the first time you begin your app, the new line is not appended as new line, but as a continuation of the last line of your file. You should edit your original text.txt by pressing 'enter' at the end of it, and then save it, before uploading it to your dirroot or dirdefault or whatever folder you choose. One good way to debug such cases is to open your edited file by another editor. This way you can see what went wrong.

Hi mc73,
If I edit original text.txt file with press 'enter' at the end of it and then save it,it will make the blank line.
Whenever I run the widget,it have error occurred again.
 
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
did you hit 'enter' exactly at the end of 'ccc,30' ? I suspect you hit enter in a new line. please check this because when I test it, it causes no error.
 
Upvote 0
Top