View Complete Thread | FoxWeb Forum Home
Search:
Date:    Msg ID:   
From:    Thread:   
Subject:   
In addition to my post from yesterday I found that adding the path to the database (be on the network or elsewhere) to the existing path makes the code work.
 
Just my $0,02 Cool 
Sent by Boudewijn lutgerink on 02/09/2016 12:04:12 AM:
tx for that piece of code. Here is how I adjusted it:

PROTECTED FUNCTION table_assign
    LPARAMETERS tcTable
    LOCAL lcTableName as String, llFoundIt as Logical
Local Array laDBC[1]
LOCAL lcCurrentDatabase as String, lcTablePath as String, lni as Integer
lctableName = ""
llFoundIt = .F.
    IF TYPE('tcTable')<>'C' .OR. EMPTY(tcTable)
       ERROR 'Invalid or empty "'+this.name+'.Table" property'
       RETURN .F.
    ENDIF
    
    IF  .NOT. FILE(tctable)
    *-- Table is not in the search path.
    *   Look for an open database
    *
    IF ADATABASES(laDBC)>0
    lcCurrentDatabase = SET("Database")
    FOR lni = 1 TO ALEN(laDBC,1)
    SET DATABASE TO ladbc[lni,1]
    IF INDBC(tcTable,"TABLE")
    lcTablePath = ADDBS(JUSTPATH(laDBC[lni,2]))
llFoundIt = .T.    
    exit
    ENDIF
   
    ENDFOR
SET DATABASE TO (lcCurrentDatabase)    
    ENDIF
ELSE
llFoundIt = .T.    
    ENDIF
IF llFoundIt
   lcTableName = FORCEEXT(tcTable, 'dbf')
   this.table = lcTableName
   *
   IF EMPTY( lcTablePath)
   this.tablepath = ADDBS(JUSTPATH(FULLPATH(lcTableName)))
   ELSE
   this.tablepath = lcTablePath
   ENDIF
   
   this.tablename = JUSTFNAME(lcTableName)
    ELSE
ERROR 'Table specified in "'+this.name+'.Table" property does not exist'
RETURN .F.
    
    ENDIF
    
ENDFUNC

 
Sent by FoxWeb Support on 02/08/2016 12:54:26 PM:
The code definitely does not look for the table you specify through the Table property in the list of open tables. You must either specify a full path, or if it's just a file name, it must correspond to a file in the path. 
 
The Table_ASSIGN method should throw an error if it can't find the specified table. For your reference, here's the full code Table_ASSIGN:
 

**********************************************************

PROTECTED PROCEDURE Table_ASSIGN

**********************************************************

LPARAMETERS cTable

IF TYPE('M.cTable') <> 'C' OR EMPTY(M.cTable)

ERROR 'Invalid or empty ' + THIS.Name + '.Table property'

RETURN .F.

ENDIF

IF EMPTY(JUSTEXT(M.cTable))

M.cTable = FORCEEXT(M.cTable, 'dbf')

ENDIF

IF ! FILE(M.cTable)

ERROR 'Table specified in ' + THIS.Name + '.Table property does not exist'

RETURN .F.

ENDIF

THIS.Table = M.cTable

THIS.TablePath = ADDBS(JUSTPATH(FULLPATH(M.cTable)))

THIS.TableName = JUSTFNAME(M.cTable)

ENDPROC 

 
 
FoxWeb Support Team
support@foxweb.com email
 
Sent by Boudewijn lutgerink on 02/08/2016 06:49:03 AM:
After some thinking and testing I think I know what is going on in the table_assign method.
 
As long as the data is in the search path the table is neatly added to the object.
HOWEVER, (and here is the thing!) I have my database on a network drive that can be accessed through several settings depending on the machine where I work on (for one machine it could be the H: drive on another machine it could be the Z: drive.
I open the database depending on some settings in an ini file, again, modified per machine.

So my assumption now is that in the aforementioned method the adatabases() and INDBC() functions are not used.
 
What would be useful then is check if a database IS open (aDatabases() function)
then check with the indbc() function whether the table is in the database and then add the table to the table property of the search object.
 
just my $0.02 (about €0.018) Wink
Sent by Boudewijn lutgerink on 02/06/2016 01:30:31 AM:
 Out of the blue the fulltextsearch object doesn't recognize the "table=" setting.
I open the database
create the textsearch object
TRY TO fill the table property
However, no matter what I do it doesn't get filled.
 
here are the steps I take:
 
  • Open the database
  • set the table property, no result
  • "use" the table
  • set the table property, no result
  • set the table property with a full path (never did that before), no result.
  • use the table exclusive
  • set the table property, no result
I tested against the errors property but that returns 0 errors. thus no description, severity or anything else useful.
 
What is going on here?Yell This is driving me bonkers.