Android Question not save txt, whi?

fifiddu70

Well-Known Member
Licensed User
Longtime User
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Thermal Printer -> DC:0D:30:02:6F:C9
tavolo34
Pizzeria
1 : Pizza Belvedere - Euro 5.00

===========================

*COMANDA Numero: 5 - 26/03/2017 - ORE:00.14
Operatore: Anonimo - Tavolo: 34
Primi
Note:
TOTALE EURO: 5.00.txt
/storage/emulated/0/Tavolo
Thermal Printer -> DC:0D:30:02:6F:C9
tavolo34
Pizzeria
1 : Pizza Belvedere - Euro 5.00

===========================

*COMANDA Numero: 5 - 26/03/2017 - ORE:00.14
Operatore: Anonimo - Tavolo: 34
Primi
Note:
TOTALE EURO: 5.00.txt
/storage/emulated/0/Tavolo
 
Upvote 0

fifiddu70

Well-Known Member
Licensed User
Longtime User
ok make done, i have modify this code:
B4X:
Sub Timer1_Tick
    If connected Then
       
        If TextReader1.Ready Then 'check if there is any data waiting to be read
            txtLog.Text = txtLog.Text & TextReader1.ReadLine & CRLF
            txtLog.SelectionStart = txtLog.Text.Length
            txtdisplay.Text=txtLog.Text
           
           
            Dim k As Int
            k = txtLog.Text.IndexOf("id ")' eseguo la ricerca di Tavolo: per poter estrapolare solo la cifra da inserire nella txteuro.text ' this modify with id replaced with Tavolo: 
            If k >= 0 Then
                txttavolo.Text = txtLog.Text.SubString2(k + 2, txtLog.Text.Length)' da qui estrapolo il tavolo
               
               
                End If
            End If
    End If
   
   
   
End Sub
in app to trasmit data in this app, i have modified order of writing flush,
example:
B4X:
Sub btnprint_Click
    mp1.Load(File.DirAssets,"click.wav")
    mp1.Play
    DateTime.DateFormat="dd/MM/yyyy"
    DateTime.TimeFormat="HH.mm"
    If txteuroparziale.Text="" Then
    Else
    End If
       
    If connected Then
       
        btncalcola_Click
        contatore= contatore +1
        txtcontatore.Text=contatore
       
        TextWriter1.WriteLine("COMANDA" & " Numero: " & txtcontatore.Text & " - " & DateTime.Date (now) & " - ORE:" &  DateTime.Time (now) & CRLF)
        TextWriter1.WriteLine("Operatore: " & txtoperatore.Text &  " - Tavolo: " & txttavolo.Text & CRLF)
        TextWriter1.WriteLine(" " & lblm1.Text & " " &  CRLF)
        For i = 0 To lswordine2.Size -1
            TextWriter1.WriteLine(lswordine2.GetItem(i) & CRLF)
           
           
        Next
        TextWriter1.WriteLine("                            " & CRLF)
        TextWriter1.WriteLine("===========================" & CRLF)
        TextWriter1.WriteLine("                            " & CRLF)
        TextWriter1.WriteLine("COMANDA" & " Numero: " & txtcontatore.Text & " - " & DateTime.Date (now) & " - ORE:" &  DateTime.Time (now) & CRLF)
        TextWriter1.WriteLine("Operatore: " & txtoperatore.Text &  " - Tavolo: " & txttavolo.Text & CRLF)
        TextWriter1.WriteLine(" " & lblm2.Text & " " & CRLF)
        For i = 0 To lswordine.Size -1
            TextWriter1.WriteLine(lswordine.GetItem(i) & CRLF)
           
        Next
        TextWriter1.WriteLine(" Note: " & txtnote.Text & CRLF)
        TextWriter1.WriteLine("TOTALE EURO: " & txttotaleeuro.Text   & CRLF)
        TextWriter1.WriteLine("id " & txttavolo.Text & CRLF) ' this code added after modify, before substring index ("TAvolo:")  now substring ("id ") 
        TextWriter1.WriteLine("                    ")
        TextWriter1.WriteLine("                    ")
        TextWriter1.WriteLine("                    ")
        TextWriter1.Flush
            
 

        End If
            mnuDisconnect_Click
        Msgbox("Comanda inviata","ESEGUITO")
       
    Else
        mp1.Load(File.DirAssets,"alert.wav")
        mp1.Play
        Msgbox("Attenzione connetti la stampante","STAMPANTE NON CONNESSA")
    End If

  

   
End Sub

before when write the file and make txt, the problem is space empty form Tavolo: to .txt now i have added id in last line writable ( the code work now ).
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…