FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Translate words in dbf fields with other words
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Translate words in dbf fields with other words
Posted: Fri Mar 20, 2020 02:43 PM

Hello,

I want to translate words from products data into my language.

I was thinking of a Xbrowse with 2 columns

Flemisch - English

Zwart - Black
Broek - Trouwsers
Broek - Trouwser
etc...

The product database will then be checked for the field "Description" and find all englisch words to convert.../ changed in the same dbf.
There are so many functions ))

I have seen functions like : dbftoarr, At, Tokens, ....

Can i have a start idea to proceed ?

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Translate words in dbf fields with other words
Posted: Fri Mar 20, 2020 05:09 PM
You need to translate whole words, searching case-insensitive.

Use this function
Code (fw): Select all Collapse
FW_AT( acSub, cString, nStart, nEnd, lWholeWord, lSkipQuotes, cFound, cReplace, lAll )


in this manner:

Code (fw): Select all Collapse
aTranslate := ;
   {  { "Zwart", "Black" } ;
   ,  { "Broek", "Trouwsers" } ;
   ,  { "Broek", "Trouwser" } ;
   }
   
   do while !eof()
   
      cDesc := FIELD->DESCRIPTION
      for n := 1 to Len( aTranslate )
         FW_AT( aTranslate[ n, 2 ], @cDesc, nil, nil, .t., .f., nil, aTranslate[ n, 1 ], .t. )
      next
      FIELD->DESCRIPTON := cDesc
      
      SKIP
   enddo
Regards



G. N. Rao.

Hyderabad, India
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Translate words in dbf fields with other words
Posted: Fri Mar 20, 2020 08:11 PM

Very Nice and working. Thanks !

Marc Venken

Using: FWH 23.08 with Harbour

Continue the discussion