Hi all,
I get different effects on FileGet on Desktop or Device.
I read a Textfile with FileGet, because I want to access lines at particular points later on.
The startByte of every Line is saved in a FilePointer-List FP (array).
One set of Data is read and looked for CrLf.
This tells where the new Line begins.
On the Desktop everything works fine.
see first Attachment:
The Number tells the startByte to read from, the text is from the File at that point up to CrLf.
On the Device sometimes there comes up failures.
see second Attachement:
In line 8 (the startByte 122 is correct) there is one. Line 9 is an aftereffect.
The last two lines are a failure again. The startByte 255 is correct.
Does anybody has an idea.
Code and Textfile is attached.
Thanks a lot
Bernd
This is created with version 5.
But compiled with version 6 is the same.
As well if I compile on the device with Version 6.01.
.Net Version on the Device is: 2.0.7045
The code is condensed from a larger app.
I get different effects on FileGet on Desktop or Device.
I read a Textfile with FileGet, because I want to access lines at particular points later on.
The startByte of every Line is saved in a FilePointer-List FP (array).
One set of Data is read and looked for CrLf.
This tells where the new Line begins.
On the Desktop everything works fine.
see first Attachment:
The Number tells the startByte to read from, the text is from the File at that point up to CrLf.
On the Device sometimes there comes up failures.
see second Attachement:
In line 8 (the startByte 122 is correct) there is one. Line 9 is an aftereffect.
The last two lines are a failure again. The startByte 255 is correct.
Does anybody has an idea.
Code and Textfile is attached.
Thanks a lot
Bernd
This is created with version 5.
But compiled with version 6 is the same.
As well if I compile on the device with Version 6.01.
.Net Version on the Device is: 2.0.7045
The code is condensed from a larger app.
B4X:
Sub Globals
'Declare the global variables here.
nHeader =3
eof_ = false
Dim c1
z=0
End Sub
Sub App_Start
Sip(False)
num1.Visible = false
AddArrayList("FP") ' FilePointer
Form1.Text="AltiRoute"
Form1.Show ' muß vor drawer stehen
tb1.Text=""
End Sub
Sub mnLoad_Click
open1.Filter = "rt2 Files|*.rt2|AllFiles|*.*"
If open1.Show = cCancel Then Return
If FileExist (open1.File) = true Then
Form1.Text = open1.File
eof_ = false
FP.clear ' FilePointer
FileClose(c1)
'FileOpen (c1,open1.File,cRead ,, cASCII)' doesn't work with FileGet
FileOpen (c1,open1.File,cRandom)
FP.add(0) ' FilePointer first Value
For i = 1 To nHeader
header =getLine(FP.Item(FP.count-1))
'header = FileRead (c1)
FP.add(getFP(header))
Next
'line1 = FileRead (c1)
line1 =getLine(FP.Item(FP.count-1))
FP.add(getFP(line1))
Do
'line1 = FileRead (c1)
line1 =getLine(FP.Item(FP.count-1))
FP.add(getFP(line1))
z=z+1
Loop Until (line1 = EOF)or(EOF_)or(z>10)
End If 'If FileExist
End Sub
Sub getLine(FP1)
tb1.Text=tb1.Text &crlf &FP1 &" " 'for debugging
l1 =FileGet(c1,FP1,50)
'l1 =FileGet(c1,143,50) 'for debugging
'tb1.Text=tb1.Text &l1 &"*" &crlf 'for debugging
Pos = StrIndexOf(l1,crlf,0)
'truncate inputline at crlf
If Pos <> -1 Then
l1 =SubString(l1,0,Pos)
End If
If StrIndexOf(l1,",",0) = -1 Then
eof_ = true
Else
eof_ = false
End If
tb1.Text=tb1.Text &l1 'for debugging
Return l1
End Sub
Sub getFP(l1) 'next value for FilePointer-List
Return FP.Item(FP.count-1) +StrLength(l1)+2 ' +2: Cr Lf
End Sub
Sub Form1_Close
FileClose (c1)
End Sub