FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Problem with dbseek
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Problem with dbseek
Posted: Wed Jun 08, 2016 04:55 PM

I have a cicle For Next and on this cicle I have a dbseek to search on archive a text i I have on a array because I must change a quantity on a archive

the procedure found only the first text ... why ?

I made :

Local nOldInven:=0
Local nInven:= 0
Local m
Local cTags:="text1; text2; text3 ;" //this is the field i have
Local aNew:=:=iif(AT(';',cTags)!=0, HB_ATokens( cTags, ";"), {}) // I converte on an array

SELECT ET //open ET
ET->(DbSetOrder(1)) //Order on Et->ETNOMBRE ( character )
ET->(DbGoTop())

For m=1 to Len(aNew)
IF!Empty( Upper(Rtrim(aNew[m])))
IF ET->(DbSeek( Upper(Rtrim(aNew[m])), .t. ))
nOldInven:= ET->ETINVEN
nInven:= nOldInven+1
Replace ET->ETINVEN WITH nInven
ET->(DbCommit())
Endif
Endif
next m

where is the error ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: Problem with dbseek
Posted: Wed Jun 08, 2016 05:41 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Problem with dbseek
Posted: Wed Jun 08, 2016 05:49 PM

Karina but you understtod my problems ?

Local cTags:="Computer; Televisore; Portatile;"
Local aNew:=iif(AT(';',cTags)!=0, HB_ATokens( cTags, ";"), {})

return an array with 4 rows instead of 3 rows ....

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Problem with dbseek
Posted: Wed Jun 08, 2016 07:52 PM
Silvio,

that returns 3 elements

Code (fw): Select all Collapse
aNew := {}
cTags :="Computer; Televisore; Portatile;" 
FOR I := 1 TO StrCharCount( cTags, ";" )
    AADD( aNew, { StrToken( cTags, I, ";" ) } ) 
    MsgAlert( aNew[I][1], "Array" ) // returns 3 elements
NEXT


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM
Re: Problem with dbseek
Posted: Thu Jun 09, 2016 02:52 AM
Silvio,

I don't think you should use ';' at the end of the string,
when you are not continuing with more items, separated by ";".
Hb_Atokens might be assuming a blank value, when the string
is ended with ";"


As per xHarbour Reference Documentation:
The delimiter is removed from <cString> and the resulting substrings are collected in an array, which is returned.


-Ramesh Babu
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Problem with dbseek
Posted: Thu Jun 09, 2016 07:35 AM
Friends
the array was the first problem
there ia another problem I explain you

Now I must found on a archive each aNew[i] string and add +1 on field ETINVEN( numeric)
Etichette.dbf have two field :

1. Etnombre 40 cr
2. EtInven numeric 3
nlen:=Len(aNew)

USE ETICHETTE ALIAS ET
INDEX ON upper(ET->ETNOMBRE) TAG ET01 TO ETICHETTE

For m=1 to nlen
Msginfo(upper(rtrim(aNew[m][1])))

ET->(DbGoTop())

IF ET->(DbSeek( upper(rtrim(aNew[m][1])), .t. ))

Msginfo("trovato: "+upper(rtrim(aNew[m][1])) )

nOldInven:= ET->ETINVEN
nInven:= nOldInven+1
Replace ET->ETINVEN WITH nInven

Endif


next
ET->(DbCommit())



the problem is it found only one element and then exit from cicle for...next WHY ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Problem with dbseek
Posted: Thu Jun 09, 2016 07:55 AM

Sorry I resolved...yesterday last night I needed to relax .....I am old now

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Problem with dbseek
Posted: Thu Jun 09, 2016 02:02 PM

Silvio,

Good to hear you found the solution.

I think most of us programmers can't walk away from a problem until we solve it. We are driven.

Ironically, the solution comes to us after we have walked away and are doing something else totally unrelated. It is just so hard to walk away...

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Problem with dbseek
Posted: Fri Jun 10, 2016 05:50 PM

James,

I sent you an email yesterday. I don't know if maybe the address changed ? Relative to possible issues between tRecord and tDatabase.

Tim

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit

Continue the discussion