Getting "Open Error" using test.dbf on android phone

Getting "Open Error" using test.dbf on android phone

Postby Gale FORd » Wed Jul 01, 2015 4:37 pm

Using controls.prg I am having a problem using test.dbf on android phone. I have tried it on 2 different devices.
I modified the controls.prg sample you provided and added a check for test.dbf right before the use statement.

Here is the relevant section of controls.prg.
Code: Select all  Expand view

   if file( "test.dbf" )
      msginfo( "test.dbf found" )
   else
      msginfo( "test.dbf NOT found" )
   endif
   USE TEST

   @ 20, 300 SAY oSay PROMPT "Browse" OF oDlg

   @ 20, 380 BROWSE oBrw OF oDlg ;
             SIZE 400, 300 ;
             HEADERS "FIRST", "LAST" ;
             FIELDS FIELD -> first, FIELD -> last
 

When I run the code it pops up message saying “test.dbf found” which is good.
Then when you press ok button it gets open error. If I comment out //use test
Then it gets dbedit error so I know it is on the “use test” statement.

I have tried searching on the internet but couldn’t find anything to help.
Have you been able to use dbf on android phone?

By the way DISTFILES += test.dbf does not get test.dbf onto android in any accessible location.
I added to FiveTouch.prg a little program like your other sample prgs to check for test.dbf in all normal android directories.
Then if it finds it in download directory it copies it and checks all directories again.
Here is that code.
Code: Select all  Expand view

// GFCheckDownload.prg

TEXT INTO cCode
#include "FiveTouch.ch"
function GFCheckDownload()
   local cDownloadDir
   local cDataDir
   local cFile := "test.dbf"
   local cMemo := ""
   local nCounter, cDir
   cDownloadDir := DownloadLocation()+"/"
   cDataDir := DataLocation()+"/"
   // Before updating Test.dbf from download dir Check all folders
   cMemo += "Check Directories Before"+CRLF
   for nCounter := 1 to 14
      cDir := QStandardPaths():StandardLocations( nCounter ):Value( 0 )
      cMemo += str(nCounter,2)+" "+cDir+CRLF
      if .not. empty( cDir ) // If empty must be current directory
         cDir += "/"
      endif
      if file( cDir+cFile )
         cMemo += "Test.dbf Found"+CRLF
      endif
   next
   if file( cDownloadDir+cFile )
      // move test.dbf from download directory
      cMemo += CRLF
      cMemo += "Test.dbf copied from download dir"+CRLF
      memowrit( cDataDir+cFile, memoread(cDownloadDir+cFile))
      memowrit( cFile, memoread(cDownloadDir+cFile))
      //__CopyFile( cDownloadDir+cFile, cDataDir+cFile )
      //__CopyFile( cDownloadDir+cFile, cFile )

      // ferase() does not seem to work on download directory. Must be permission issue
      //ferase( cDownloadDir+cFile )

      // Now check all folders for test.dbf
      cMemo += CRLF
      cMemo += "Check Directories After"+CRLF
      for nCounter := 1 to 14
         cDir := QStandardPaths():StandardLocations( nCounter ):Value( 0 )
         cMemo += str(nCounter,2)+" "+cDir+CRLF
         if .not. empty( cDir ) // If empty must be current directory
            cDir += "/"
         endif
         if file( cDir+cFile )
            cMemo += "Test.dbf Found"+CRLF
         endif
      next
   else
      cMemo += "Test.dbf not found in download dir"+CRLF
   endif
   MemoWrit( "FileInfo.txt", cMemo )
   OpenFile( "FileInfo.txt" )
return nil
ENDTEXT

MemoWrit( "GFCheckDownload.prg", cCode )
 

Here is the results after running it.
    Check Directories Before
    1 /storage/emulated/0/Documents
    2 /system/fonts
    3
    4 /storage/emulated/0/Music
    5 /storage/emulated/0/Movies
    6 /storage/emulated/0/Pictures
    7 /data/data/fivetech.WWMobile/cache
    8 /data/data/fivetech.WWMobile/files
    9 /data/data/fivetech.WWMobile/files
    10 /data/data/fivetech.WWMobile/cache
    11 /storage/emulated/0
    12 /data/data/fivetech.WWMobile/cache
    13 /data/data/fivetech.WWMobile/files/settings
    14 /storage/emulated/0/Download
    Test.dbf Found

    Test.dbf copied from download dir

    Check Directories After
    1 /storage/emulated/0/Documents
    2 /system/fonts
    3
    Test.dbf Found
    4 /storage/emulated/0/Music
    5 /storage/emulated/0/Movies
    6 /storage/emulated/0/Pictures
    7 /data/data/fivetech.WWMobile/cache
    8 /data/data/fivetech.WWMobile/files
    Test.dbf Found
    9 /data/data/fivetech.WWMobile/files
    Test.dbf Found
    10 /data/data/fivetech.WWMobile/cache
    11 /storage/emulated/0
    12 /data/data/fivetech.WWMobile/cache
    13 /data/data/fivetech.WWMobile/files/settings
    14 /storage/emulated/0/Download
    Test.dbf Found
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Getting "Open Error" using test.dbf on android phone

Postby Gale FORd » Wed Jul 01, 2015 7:34 pm

I changed the code from "use test" to add some error handling and it seem to work .
Controls.prg works with the changed code below. (and copying test.dbf from download directory of coarse)

Code: Select all  Expand view
  if file( "test.dbf" )
      msginfo( "test.dbf found" )
   else
      msginfo( "test.dbf NOT found" )
   endif
   bErrorBlock := ErrorBlock( {|| Break( Nil ) } )
   BEGIN SEQUENCE
      dbUseArea( .t. , "DBFCDX", "test.dbf",, .t.)
   RECOVER USING oErr
      msginfo( oErr:Description )
   END SEQUENCE
   ErrorBlock( bErrorBlock )
   //USE TEST

 
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Getting "Open Error" using test.dbf on android phone

Postby Antonio Linares » Wed Jul 01, 2015 7:45 pm

Gale,

I think this line made the difference:

dbUseArea( .t. , "DBFCDX", "test.dbf",, .t.)

as it specifies the RDD to use

Glad to know that you are progressing with FiveTouch. I am aware we go slowly but we keep moving forward :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveTouch

Who is online

Users browsing this forum: No registered users and 1 guest