Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Problem with FileGet on Device

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-25-2008, 12:41 PM
Junior Member
 
Join Date: May 2007
Location: Germany
Posts: 45
Default Problem with FileGet on Device

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.
Code:
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
Attached Images
File Type: jpg Desktop FileRead.jpg (18.9 KB, 24 views)
File Type: jpg Device FileRead.jpg (18.8 KB, 17 views)
Attached Files
File Type: zip CodeAndText.zip (4.2 KB, 11 views)
Reply With Quote
  #2 (permalink)  
Old 04-25-2008, 03:16 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Why don't you use a (hidden) Table and load the data with LoadCSV ?
Reply With Quote
  #3 (permalink)  
Old 04-25-2008, 03:31 PM
Junior Member
 
Join Date: May 2007
Location: Germany
Posts: 45
Default

Ok, I can do a workaround.

But why there is that difference.

Is there a failure in my code, or is it bug?

Thanks
Bernd
Reply With Quote
  #4 (permalink)  
Old 04-25-2008, 03:34 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Quote:
Originally Posted by BerndB View Post
Ok, I can do a workaround.
It will be much faster and simpler to use a table.

Quote:
Originally Posted by BerndB View Post
But why there is that difference.

Is there a failure in my code, or is it bug?
I'm checking it right now.
Reply With Quote
  #5 (permalink)  
Old 04-25-2008, 03:39 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hi BerndB,

I have tried your code on my desktop and on my Qtek 9090 WM2003,
and get the same problem.

I have added a textbox on your Form and MsgBoxes to go step by step and there are lines not read correctly (new code joined).
After these investigatios there is a problem with the FileGet function on the device.

I added a line
tx=FileGet(c1,122,40) '???????????????????
and with this additional line it works.
Why I don't know, perhaps Erel should have a look at this.

Best regards
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #6 (permalink)  
Old 04-25-2008, 08:56 PM
Junior Member
 
Join Date: May 2007
Location: Germany
Posts: 45
Default

Hi Erel,
Hi Klaus,

thanks for your investigations!

it even works with a dummy-read like this:

tx=FileGet(c1,1,0)

Concerning the workaround:
One reason why I work with FileGet is, that I access as well Files with a altitude- model witch have a size of about 4 MB with 6000 lines * 6000 columns.
There I want to pick every single altitude for the Koords e.g. in that Route file attached to create a altitude profile.
I didn't think of loading the whole 4MB into the app. Specially because it could be that i have to pick the altitudes from different altitude-files.

Erel, would you advise to load Files of that size into a table?

Thank you in respect of your time spending for b4PPC.

regards
Bernd
Reply With Quote
  #7 (permalink)  
Old 04-26-2008, 05:15 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

4MB is too large for a table.
However it will also be too slow using FileGet or FileRead.
The best solution is to convert the data to a SQLite database.
Reply With Quote
  #8 (permalink)  
Old 04-28-2008, 04:04 PM
Junior Member
 
Join Date: May 2007
Location: Germany
Posts: 45
Default

Thank you for your hint Erel.

I never worked with SQL.

So it seems it's time to get into it.

regards
Bernd
Reply With Quote
  #9 (permalink)  
Old 05-10-2008, 01:25 AM
Junior Member
 
Join Date: May 2007
Location: Germany
Posts: 45
Question sqlite table access by row & column

Hi friends of sqlite,

I have a file with altitude levels converted to a sql-table.
Now I want to access the table by row and column.

What I found in the forum is this:

Code:
  Reader.New1
  cmd.CommandText = 
"Select Alti.* from Alti Limit 1 offset 2"
  Reader.Value = Cmd.ExecuteReader 
  
Msgbox(Reader.GetValue(3))
Alti is my Table
and with this code I get the content of the field from row 3 (offset 2) and column 4 (GetValue(3).

What I couldn't find is how to replace the integer for offset (2 in this case) with a variable.

Can somebody help me to get a quick random access on a sql-table (with use of variables).

Thanks a lot
Bernd
Reply With Quote
  #10 (permalink)  
Old 05-10-2008, 05:24 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

cmd.CommandText is a simple string:
Code:
cmd.CommandText = "Select Alti.* from Alti Limit 1 offset " & Variable
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between FileGet and FileGetByte BjornF Questions (Windows Mobile) 6 10-29-2008 08:34 AM
wm5 device-path problem enonod Questions (Windows Mobile) 4 05-26-2008 04:28 PM
Optimized Compilation problem on the device bob Questions (Windows Mobile) 4 03-12-2008 01:05 PM
Version 6.0 Device optimized compilation problem HarleyM Bug Reports 0 12-28-2007 02:01 AM
Networking (DNS?) device problem agraham Questions (Windows Mobile) 2 11-07-2007 06:24 PM


All times are GMT. The time now is 09:20 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0