If anyone is interested, here's the library routine I wrote to determine
which
file could be used for a query - X01..XG9 if 2nd index, DB otherwise:
;---- start ------
var
saveTableExtAR array[] string
saveTableExtDyn dynArray[] string
endVar
method getQueryTableExt(var tcIn tcursor, curTab string, curField string)
string
var
idxTC,
tc tcursor
endVar
curExt = "db"
while true
if saveTableExtAR.size() > 0 then
if saveTableExtAR.contains(curTab) then ; only first time
quitloop
endif
endif
iTab = ":priv:queryExt.db"
ok = tcIn.isAssigned()
if ok then
ok = tc.attach(tcIn)
else
ok = tc.open(curTab)
endif
if ok then
ok = tc.enumIndexStruct(iTab)
endif
if ok then
ok = idxTC.open(iTab)
endif
if not ok then
errorShow()
return(curExt)
endif
extStr = ""
addIt = true
scan idxTC :
if not idxTC.iIndexID.isBlank() then
curIdxStr = toHex(idxTC.iIndexID)
maxI = curIdxStr.size()
if maxI > 3 then
if curIdxStr.subStr(maxI - 2,1) <> "0" then
extStr = "XG" + curIdxStr.subStr(maxI,1) ; 256: 0x00000100 =
XG0
else
extStr = "X" + curIdxStr.subStr(maxI-1,2) ; 1: 0x00000001 = X01
endif
endif
endif
curSlot = curTab + ":" + upper(idxTC.FieldName)
if extStr <> "" then
saveTableExtDyn[curSlot] = extStr
if addIt then
saveTableExtAR.addLast(curTab)
addIt = false
endif
endif
endScan
quitloop
endWhile
if saveTableExtAR.contains(curTab) then
curSlot = curTab + ":" + curField
if saveTableExtDyn.contains(curSlot) then
curExt = saveTableExtDyn[curSlot]
endif
endif
return(curExt)
endMethod
;------- end -------
The calling form's code can be this easy, though if you have multiple
columns
or tables it gets more complicated:
Uses ObjectPal
getQueryTableExt(var tc tcursor, curTab string, curField string) string
endUses
;...
masterTab = "Customer"
if tc.dmattach("MASTER") then
tabExt = lUtil.getQueryTableExt(tc, masterTab, srchFld)
if tabExt <> "" then
masterTab = masterTab + "." + tabExt
endif
endif
qry1 = "Query "
qry1 = qry1 + "\n\n" + masterTab + " | CustNo | "
qry1 = qry1 + "\n" + " | Check > 0 |\n\n"
qry1 = qry1 + masterTab + " | " + srchFld + " | "
qry1 = qry1 + "\n | " + srchFor + " |"
qry1 = qry1 + "\n\n" + "EndQuery "
ok = q.readFromString(qry1)
if ok then
ok = qrySave.executeQBE()
endif
if not ok then
errorShow()
endif


|