Android Question Error declaring variable

MarcioCC

Member
Licensed User
Longtime User
Good night, I'm using
The following error code is displayed: TextWriter1.Initialize (File.OpenOutput (File.DirDefaultExternal, $ "$ {lbl_chamaMEI.Tag} .txt" $, False))

Error description: Undeclared variable 'lbl_chamamei' is used before it was assigned any value.

what am I doing wrong?? Follow the code...


B4X:
Sub BtnGeraInv_Click
     
                  Dim lbl_chamaIMEI As Label
                               
         Qry="SELECT CODBARRAS,QUANTIDADE FROM PRODUTOS ORDER BY CODBARRAS"
         Cursor1=SQL.ExecQuery(Qry)
         If Cursor1.RowCount=0 Then
         Cursor1.Close
         Return
End If

            Lbl_IMEI.Text = GetDeviceId
           
            lbl_chamaIMEI = Lbl_IMEI.Text
       
            lbl_chamaIMEI.Tag = "lbl_chamaIMEI"
           
            ERROR IN THIS LINE --->TextWriter1.Initialize (File.OpenOutput                      (File.DirDefaultExternal,$"${lbl_chamaMEI.Tag}.txt"$ , False))
             ERROR MESSAGE ---> Undeclared variable 'lbl_chamamei' is used before it was assigned any value.

   For i = 0 To Cursor1.RowCount-1
   Cursor1.Position=i
   CODBARRAS= Cursor1.GetString("CODBARRAS") 
   QUANTIDADE = Cursor1.GetString("QUANTIDADE") 
   
   TextWriter1.Write(CODBARRAS & "," & QUANTIDADE & Chr(13) & Chr(10))
   
    
Next
TextWriter1.Flush
TextWriter1.Close
Cursor1.Close
Msgbox("Inventário Gerado com Sucesso !!","Coletor de Dados MPC®")

   
End Sub
 

monic

Active Member
Licensed User
Longtime User
lbl_chamaMEI should is not be lbl_chamaIMEI ?

TextWriter1.Initialize (File.OpenOutput (File.DirDefaultExternal, $ "$ {lbl_chamaIMEI.Tag} .txt" $, False))
 
Upvote 0

monic

Active Member
Licensed User
Longtime User
A Label is an 'Activity Object', so it cannot be declared under Process_Globals
 
Last edited:
Upvote 0

MarcioCC

Member
Licensed User
Longtime User
The code worked perfectly only that there is still a problem, I'm getting the IMEI of the device and playing on the label I want to generate a .txt file with the device IMEI example: BY900f4g7G.txt I am using this code to generate the .txt:

Lbl_IMEI.Text = GetDeviceId

Lbl_IMEI.Tag = "lbl_IMEI"


TextWriter1.Initialize (File.OpenOutput
(File.DirDefaultExternal, $ "$ {Lbl_IMEI.Tag} .txt" $, False))

It compiles more the .txt file has the name Lbl_IMEI.txt, how do I get the IMEI from the device ?? (BY900f4g7G.txt)
Does anyone have an example ??
 
Upvote 0

monic

Active Member
Licensed User
Longtime User
The code worked perfectly only that there is still a problem, I'm getting the IMEI of the device and playing on the label I want to generate a .txt file with the device IMEI example: BY900f4g7G.txt I am using this code to generate the .txt:

Lbl_IMEI.Text = GetDeviceId

Lbl_IMEI.Tag = "lbl_IMEI"


TextWriter1.Initialize (File.OpenOutput
(File.DirDefaultExternal, $ "$ {Lbl_IMEI.Tag} .txt" $, False))

It compiles more the .txt file has the name Lbl_IMEI.txt, how do I get the IMEI from the device ?? (BY900f4g7G.txt)
Does anyone have an example ??

Try this library : https://www.b4x.com/android/forum/threads/simcard-also-dual-sim.51301/
 
Upvote 0
Top