Sub Accelerometer_AccelerometerChanged (X As Float, Y As Float, Z As Float)
Dim Ax As Float
Dim Ay As Float
Dim Az As Float
Ax=X
Ay=Y
Az=Z
xval.Text=Ax
yval.Text=Ay
zval.Text=Az
File.WriteString(File.DirRootExternal, "myaccval.txt", xval.Text&","&yval.Text&","&zval.Text)
End Sub
the code writes only 1 line in the text file. How can i make it write accelerometer values as they are shown in the labels? i want to capture x,y,z values as they change. i have tried looping using do while but it doesn't work
It still writes only 1 line. Accelerometer values keep changing very fast and i want to capture all of them (save them in a textfile one after the other)
sure one line... The command File.writestring open(recreate) or create a file and write the text to it and close the file. There is no possibility to APPEND to this file...
B4X:
Sub WriteTextWriter
Dim TextWriter1 As TextWriter
TextWriter1.Initialize(File.OpenOutput(File.DirRootExternal, "GPS_log.txt", True))
TextWriter1.WriteLine(time1 & "," & lat & "," & lon & "," & speed)
TextWriter1.Close
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
For i = 1 To 10
WriteTextWriter("Testline "&i)
Next
End Sub
Sub WriteTextWriter(text As String)
Dim TextWriter1 As TextWriter
TextWriter1.Initialize(File.OpenOutput(File.DirRootExternal, "log.txt", True))
TextWriter1.WriteLine(text)
TextWriter1.Close
End Sub