MEM:file.dbf Fails in USB drive

156 views
Skip to first unread message

Yakano

unread,
Dec 8, 2022, 2:09:22 AM12/8/22
to Harbour Users

Hello guys

I ask you for help with a piece of code that does not work for me and I can't solve it by myself. 

   // Creo temporales en memoria desde DBF abierto
   aStruct := dbStruct()
   nSeg := Int(Seconds()*100)
   cFileDbf := "mem:TMP"+Right(StrZero(nSeg),5)+".DBF"
   dbCreate(cFileDbf, aStruct)
   cFileCdx := "mem:TMP"+Right(StrZero(nSeg+1),5)+".CDX"

This works for me when the application is used on a fixed drive (both local and network), but when running from a flash drive on a USB drive, it returns creation error... 

"Error DBFCDX/1004 Error de creación"

Any idea why this might be happening? 

Best regards

Vlademiro Landim

unread,
Dec 9, 2022, 1:03:17 AM12/9/22
to Harbour Users
Yakano

Try this:
REQUEST HB_MEMIO
REQUEST DBFCDX
PROCEDURE MAIN

   LOCAL aStr := {}
   AADD( aStr, { "COD" , "C" , 10 , 0 } )
   AADD( aStr, { "NAME" , "C" , 100 , 0 } )
   AADD( aStr, { "SALARY" , "N" , 12 , 2 } )

   dbCreate( "teste", aStr )


   //---Begin
   use teste via "DBFCDX"
   index on name to teste desc
   aStruct := dbStruct()
   close

   nSeg := Int(Seconds()*100)
   cFileDbf := "mem:TMP"+Right(StrZero(nSeg),5)+".DBF"
   dbCreate(cFileDbf, aStruct,"DBFCDX",.T.)
   //cFileCdx := "mem:TMP"+Right(StrZero(nSeg+1),5)+".CDX"
   FOR X := 1 to 100
       Append Blank
       REPLACE COD WITH STRZERO(x,3)
       REPLACE NAME WITH "USER " + FIELD->COD
       REPLACE SALARY WITH 100+X
   NEXT
   go top
   BROWSE()


You must call REQUEST HB_MEMIO
I don't understand cFileCdx

Yakano

unread,
Dec 11, 2022, 7:02:10 AM12/11/22
to Harbour Users
Hi vlademi...

Your code doesn't work when I use "REQUEST HB_MEMIO" (undefined reference to `HB_FUN_HB_MEMIO'), but removing it does work on a fixed disk. 

It doesn't work when copying the same executable to a flash drive and trying from there... (coverable error 9003: Too many recursive error handler calls | Called from DBCREATE(0)) 

You might think that dbCreate() doesn't support creating DBF files on a flash drive, but the rest of the application seems to work without problems, even creating its indexes (cFileCdx in this case). 

It only fails when MEM:FILED.DBF is requested and the executable resides on a removable drive, because if we remove MEM: everything works fine in your code (and mine). 

So why do I use MEM: ??? It is to speed up a query about events stored in a DBF without using SET FILTER, but what I already commented on is this previous post... [https://groups.google.com/g/harbour-users/c/48RAggt98bA/m /YDdRgW69BQAJ] (thanks "thefull") 

Does your code work for you when you run it from a removable drive??? 

 Best regards
Message has been deleted

Vlademiro Landim

unread,
Dec 11, 2022, 2:50:28 PM12/11/22
to Harbour Users
Hi

Compile this example with hbmemio.hbc

hbmk2 test.prg hbmemio.hbc

Vlademiro Landim

unread,
Dec 11, 2022, 2:51:38 PM12/11/22
to Harbour Users
Code attached
usb.prg

Yakano

unread,
Dec 12, 2022, 8:06:45 AM12/12/22
to Harbour Users
OK,  now is working !!!
Thanks a lot !!!

Reply all
Reply to author
Forward
0 new messages