Android Question file txt non leggibile correttamente

lelelor

Active Member
Licensed User
Buona sera, creo un file .txt con un solo campo numerico terminante con crlf, lo passo a VB6 ma non riesco a leggerlo correttamente, su 4 voci presenti ne leggo solo 2, ho altresì creato lo stesso file con una macchina con windows, con quello leggo correttamente il file. Sono ore che cerco di capire dove sia il problema ma niente...

allego i 2 file, uno chiamato GIUSTO.txt e l'altro ERRATO.txt se qualcuno riesce a svelare il mistero...

grazie mille
 

Attachments

  • ERRATO.txt
    136 bytes · Views: 226
  • GIUSTO.txt
    54 bytes · Views: 191

Pendrush

Well-Known Member
Licensed User
Longtime User
Please write in English.

In the GIUSTO.txt file, each line ends with CHR (13) + CHR (10) .... HEX 0D and 0A


In the ERRATO.txt file the lines end without consistency, somewhere there is CHR (13) + CHR (10) as for example in the first line, somewhere is only CHR (10) as for example in the second line.


You can change line end in whole file with for example notepad++
 
Last edited:
Upvote 0

lelelor

Active Member
Licensed User
sorry, I thought I was writing on the forum Italy, I suspected this, but I can not understand where I am wrong, place the command that writes me the line.
thanks and sorry again
 

Attachments

  • command write.txt
    565 bytes · Views: 241
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Why post it like this?

Post the code directly with code tags.

B4X:
Sub txtSearch_EnterPressed() 
'    Dim vuoto As String
    Dim pippo As String 
    Dim RigaDaCercare As String
    TIMER1.Enabled=True
    Dim IndexOf As Int
    Label3.Visible =False
    pippo=txtSearch.Text

    txtSearch.Text="" 
 
    lstrighe.Initialize
    lstrighe = File.ReadList(File.DirDefaultExternal, "/anaiper/hj.txt")
    
    RigaDaCercare = "pluto"
  
    IndexOf = lstrighe.IndexOf(RigaDaCercare)

    lstrighe.InsertAt(IndexOf + 1,pippo & Chr(10) & Chr(13) )
      
    File.WriteList(File.DirDefaultExternal, "/anaiper/hj.txt",lstrighe)

    txtSearch.RequestFocus 
End sub

Several mistakes:
1. File.DirDefaultExternal should never be used. Use RuntimePermissions.GetSafeDirDefaultExternal("") instead.
2. Remove this: & Chr(10) & Chr(13)
File.WriteList adds the end of line character (Chr(10)) automatically.

Note that windows end of line = Chr (13) & Chr(10)
 
Upvote 0

lelelor

Active Member
Licensed User

I did a test:
open the hj.txt file, selected everything, copied and pasted in a new file, saved as hj.txt, ALL PERFECT, why? I go crazy
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…