
I need to program a very simple Android app, whats the status of Fivetouch
Code: Select all | Expand
Get-ChildItem -Path c:\www\htdocs\fwforum\data\forumsext\POST_TEXT_memo -Recurse -Filter *.txt | Select-String -Pattern "My program creates a PDF" | ForEach-Object { $_.Path } | Out-File -FilePath "search_results.txt" -Encoding ASCII
50 Sec. is a long Time !Otto wrote: Tue Jan 21, 2025 11:10 pm I have split the DBF memo fields into TXT files, all in one directory. There are 276,748 TXT files. When I now perform a search with
it takes about 50 seconds.
Mensajes arregladosAdolfo wrote: Mon Jan 20, 2025 2:40 pm Antonio, there is no Fivetouch posts in the forum
I need to program a very simple Android app, whats the status of Fivetouch
Code: Select all | Expand
// The example shows two approaches for building a custom index.
// In the first approach, the controlling index is a regular index
// which allows for relative database navigation. The second approach
// uses the custome index as controlling index and requires absolute
// database navigation. The first five logical records and physical records
// are added to the custome index.
REQUEST Dbfcdx
PROCEDURE Main
USE Customer VIA "DBFCDX"
INDEX ON Upper(LastName+FirstName) TAG NAME TO Cust01
INDEX ON Upper(LastName+FirstName) TAG NAMESET TO Cust01t CUSTOM
// relative navigation with non-custom index
OrdSetFocus( "NAME" )
GO TOP
FOR i:=1 TO 5
OrdKeyAdd( "NAMESET" )
SKIP
NEXT
GO TOP
Browse()
// absolute navigation with custom index
OrdSetFocus( "NAMESET" )
FOR i:=1 TO 5
DbGoto( i )
OrdKeyAdd( "NAMESET" )
NEXT
GO TOP
Browse()
USE
RETURN
OrdKeyAdd()
Adds an index key to a custom built index.
Syntax
OrdKeyAdd( [<nOrder>|<cIndexName>], ;
[<cIndexFile>] , ;
[<xIndexValue>] ) --> lSuccess
Arguments
<nOrder>
A numeric value specifying the ordinal position of the custom index open in a work area. Indexes are numbered in the sequence of opening, beginning with 1. The value zero identifies the controlling index.
<cIndexName>
Alternatively, a character string holding the symbolic name of the open custom index can be passed. It is analogous to the alias name of a work area. Support for <cIndexName> depends on the RDD used to open the index. Usually, RDDs that are able to maintain multiple indexes in one index file support symbolic index names, such as DBFCDX, for example.
<cIndexFile>
<cIndexFile> is a character string with the name of the file that stores the custom index. It is only required when multiple index files are open that contain indexes having the same <cIndexName>.
<xIndexValue>
This is the index value to be added to the index for the current record. It must be of the same data type as the value returned by the index expression. If omitted, <xIndexValue> is obtained by evaluating the index expression with the data of the current record. Return
The function returns .T. (true) if the current record is successfully included in the index, otherwise .F. (false) is returned.
Description
OrdKeyAdd() is used to build a custom index whose entries are programmatically added and deleted. Custom built indexes are not automatically updated by the RDD but are initially empty. OrdKeyAdd() adds the current record to the custom index and OrdKeyDel() removes it. It is possible to add multiple index values to the index for the same record, so that the same record is found when different search values are passed to DbSeek().
If no parameters are passed, OrdKeyAdd() evaluates the index expresssion with the data of the current record to obtain <xIndexValue>. The record is added to the index when it matches the FOR condition and scoping restrictions, if they are defined. When <xIndexValue> is specified, it must have the same data type as the value of the expression &(OrdKey()).
OrdKeyAdd() fails if the record pointer is positioned on Eof(), if the specified index is not a custom index, or if the specified index does not exist.
This is important when the custom index is the controlling index. Since a custome index is initially empty, relative database navigation with SKIP positions the record pointer always at Eof(). To include records to a controlling custom index, they must be physically navigated to using DbGoto().
The recommended way of creating a custom index is to use a non-custom index as the controlling index, skip through the database and specify <cIndexName> for OrdListAdd() when the current record meets the conditions for being included in the custom index.
Code: Select all | Expand
#include "fivewin.ch"
REQUEST DBFCDX
REQUEST DBFFPT
static nCount := 0
function main
local cDBF_Dir := ".\dataTest\pages"
local cDBF_file_noPath := "c:\fwh\samples\DataTest"
local cDBF_file_memo := ""
local cDBF_fil_new := "PAGES_NEW"
local aStruc := {}
local cTmpDbf := ""
local cSrc := "c:\forumposts\forums.dbf" // "c:\fwh\samples\DataTest\PAGES.DBF"
local cDst := "c:\forumposts\forumsext.dbf" // "c:\fwh\samples\DataTest\PAGESext.dbf"
local cTempMatchcode := ""
local aFeld := {}
local aField := {}
local nField
local cFieldSubdir
local cDBF_memofiles := ""
use (cSrc) new
aStruc := DBStruct()
use
//cFilePath( cSrc ) // returns path of a filename
//cFileNoExt( cSrc ) // returns the filename without ext
cDBF_memofiles := cFilePath( cSrc ) + cFileNoExt( cSrc ) + "ext"
IF lisdir(cDBF_memofiles) = .f.
lmkdir(cDBF_memofiles)
ENDIF
// Adjust structure: Replace memo fields with character fields of length 50 and add prefix M_
FOR EACH aField IN aStruc
IF aField[2] == "M"
aField[1] := "M_" + aField[1] // Add prefix M_
aField[2] := "C"
aField[3] := 50
ENDIF
NEXT
if file(cDst) = .F.
DbCreate(cDst, aStruc)
endif
use
use(cDst) new ALIAS neuedbf
use(cSrc) new ALIAS altedbf
select altedbf
do while .not. eof()
aFeld := getrec()
// Export memo fields to txt files and save the file name in the character field
FOR nField := 1 TO fcount()
IF fieldType(nField) == "M"
cFieldSubdir := cDBF_memofiles + "\" + fieldName(nField) + "_memo"
// Create subdirectory for the memo field if not existing
IF lisdir(cFieldSubdir) = .f.
lmkdir(cFieldSubdir)
ENDIF
nCount += 1
cTempMatchcode := alltrim(str(recno())) + "-" + ShortUniqueIDNUM() + ALLTRIM( STR(nCount) )
MEMOWRIT(cFieldSubdir + "\" + cTempMatchcode + ".txt", fieldGet(nField), .F. )
aFeld[nField] := cTempMatchcode
ENDIF
NEXT
select neuedbf
APPEND_BLANK()
saverec(aFeld)
select altedbf
skip
enddo
? "Ende"
return
INIT PROCEDURE PrgInit
SET CENTURY ON
SET EPOCH TO YEAR(DATE())-98
SET DELETED ON
SET EXCLUSIVE OFF
REQUEST HB_Lang_DE
HB_LangSelect("DE")
SET DATE TO GERMAN
rddsetdefault("DBFCDX")
EXTERN DESCEND
RETURN
//----------------------------------------------------------------------------//
FUNCTION ShortUniqueIDNUM()
local cUniqueIDNUM := substr(dtos(date()),3) + "_" +;
substr(time(),1,2) + ;
substr(time(),4,2) + ;
substr(time(),7,2)
return (cUniqueIDNUM)
//----------------------------------------------------------------------------//
FUNCTION RLOK
if rlock()
RETURN ""
endif
DO WHILE .T.
if rlock()
exit
else
MsgInfo("Infobox","Datensatz gesperrt!")
endif
INKEY(.01)
ENDDO
RETURN ""
FUNCTION FLOK
if flock()
RETURN ""
endif
DO WHILE .T.
if flock()
exit
else
MsgInfo("Infobox","Datensatz gesperrt!")
endif
INKEY(.01)
ENDDO
RETURN ""
//----------------------------------------------------------------------------//
FUNCTION APPEND_BLANK
APPEND BLANK
DO WHILE NETERR()
APPEND BLANK
INKEY(.1)
ENDDO
unlock
rlok()
RETURN ""
//----------------------------------------------------------------------------//
FUNCTION unlok
unlock
RETURN (NIL)
//----------------------------------------------------------------------------//
FUNCTION net_use(vcFile,vlExclus,vnWait,vcAlias)
* tries to open a file for exclusive or shared use
*
* Syntax: NET_USE(expC1,expL1,expN1,expC2)
* where: expC1 = database to use, character string
* expL1 = .T. to use file exclusively, .F. for multi-user
* expN1 = seconds to wait if file isnt opened (0=forever), if >0,
* the calling routine must be constructed to handle cases
* where the file is not opened!
* expC2 = data driver
*
local forever := (vnWait=0)
*
do while (forever .or. vnWait>0)
if vlExclus && exclusive
use (vcFile) exclusive new
else
use (vcFile) shared new
endif
if .not. neterr() && USE succeeds
RETURN (.T.)
endif
*
inkey(1) && wait 1 second
vnWait--
ENDDO
RETURN (.F.) && database opening unsuccessful!
//----------------------------------------------------------------------------//
FUNCTION getRec()
local ary := {}
local nFcnt, nFnum
nFcnt = fcount()
FOR nFnum = 1 to nFcnt
aAdd(ary, fieldGet(nFnum))
NEXT
RETURN (ary)
//----------------------------------------------------------------------------//
FUNCTION saveRec(ary)
local nFcnt, nFnum
nFcnt = fcount()
FOR nFnum = 1 to nFcnt
fieldPut(nFnum, ary[nFnum])
NEXT
RETURN (NIL)
//----------------------------------------------------------------------------//
Code: Select all | Expand
# Pfade zu den zu durchsuchenden Verzeichnissen
$verzeichnisse = @(
"C:\www\htdocs\fwforum\data\forumsext\Dir1",
"C:\www\htdocs\fwforum\data\forumsext\Dir2",
"C:\www\htdocs\fwforum\data\forumsext\Dir3",
"C:\www\htdocs\fwforum\data\forumsext\Dir4",
"C:\www\htdocs\fwforum\data\forumsext\Dir5",
"C:\www\htdocs\fwforum\data\forumsext\Dir6",
"C:\www\htdocs\fwforum\data\forumsext\Dir7",
"C:\www\htdocs\fwforum\data\forumsext\Dir8"
)
# Pfad zur Indexdatei
$indexFile = "C:\suchergebnis\index.txt"
# Ergebnisverzeichnis sicherstellen
$ergebnisVerzeichnis = "C:\suchergebnis"
if (-not (Test-Path -Path $ergebnisVerzeichnis)) {
New-Item -ItemType Directory -Path $ergebnisVerzeichnis | Out-Null
}
# Indexdatei initialisieren (leeren oder erstellen)
if (Test-Path $indexFile) {
Clear-Content $indexFile
} else {
New-Item -Path $indexFile -ItemType File | Out-Null
}
# Funktion zur Indexerstellung
function Build-Index {
param (
[string[]]$Directories,
[string]$IndexPath
)
foreach ($dir in $Directories) {
Write-Host "Indexiere Verzeichnis: $dir" -ForegroundColor Green
# Alle .prg und .txt Dateien durchsuchen
$files = Get-ChildItem -Path $dir -Recurse -Include *.prg, *.txt -File
foreach ($file in $files) {
Write-Host " Verarbeite Datei: $($file.FullName)" -ForegroundColor Yellow
try {
# Dateiinhalt lesen
$content = Get-Content -Path $file.FullName -Raw
# Tokenisierung: Wörter extrahieren (nur alphanumerische Zeichen)
$words = $content -split '\W+' | Where-Object { $_ -match '\w+' } | ForEach-Object { $_.ToLower() }
# Einzigartige Wörter
$uniqueWords = $words | Sort-Object -Unique
foreach ($word in $uniqueWords) {
# Indexzeile: Wort<TAB>Dateipfad
"$word`t$($file.FullName)" | Out-File -FilePath $IndexPath -Append -Encoding ASCII
}
}
catch {
Write-Host " Fehler beim Verarbeiten von $($file.FullName): $_" -ForegroundColor Red
}
}
}
Write-Host "Indexierung abgeschlossen." -ForegroundColor Green
}
# Funktion zur Suche im Index
function Search-Index {
param (
[string]$SearchTerm,
[string]$IndexPath
)
$searchTerm = $SearchTerm.ToLower()
Write-Host "Suche nach: '$searchTerm'" -ForegroundColor Cyan
# Suche nach dem Wort am Anfang der Zeile (um genaue Übereinstimmung zu gewährleisten)
$pattern = "^$searchTerm`t"
$results = Select-String -Path $IndexPath -Pattern $pattern | ForEach-Object { $_.Line.Split("`t")[1] }
# Ausgabe der gefundenen Dateien
if ($results) {
Write-Host "Gefundene Dateien:" -ForegroundColor Green
$results | Sort-Object -Unique | ForEach-Object { Write-Host $_ }
}
else {
Write-Host "Keine Treffer gefunden." -ForegroundColor Yellow
}
return $results
}
# Zeitmessung starten
$startzeit = Get-Date
# Index erstellen
Build-Index -Directories $verzeichnisse -IndexPath $indexFile
# Zeitmessung beenden
$endzeit = Get-Date
$dauer = $endzeit - $startzeit
# Dauer anzeigen
Write-Host "Indexierungsdauer: $($dauer.TotalSeconds) Sekunden" -ForegroundColor Cyan
# Größe der Indexdatei messen
$indexSize = (Get-Item $indexFile).Length
Write-Host "Größe der Indexdatei: $indexSize Bytes" -ForegroundColor Cyan
# Beispielhafte Suchanfrage
$searchBegriff = "volltxtSearch"
$gefunden = Search-Index -SearchTerm $searchBegriff -IndexPath $indexFile
# Größe der Originaldateien messen
$originalSize = ($verzeichnisse | ForEach-Object {
Get-ChildItem -Path $_ -Recurse -Include *.prg, *.txt -File | Measure-Object -Property Length -Sum
}).Sum
Write-Host "Gesamtgröße der Originaldateien: $originalSize Bytes" -ForegroundColor Cyan
# Vergleich der Größen
$sizeRatio = [math]::Round(($indexSize / $originalSize) * 100, 2)
Write-Host "Indexgröße als Prozentsatz der Originaldateien: $sizeRatio%" -ForegroundColor Cyan