Problem with dbseek

Problem with dbseek

Postby Silvio.Falconi » Wed Jun 08, 2016 4: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6832
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with dbseek

Postby karinha » Wed Jun 08, 2016 5:41 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7315
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Problem with dbseek

Postby Silvio.Falconi » Wed Jun 08, 2016 5: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6832
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with dbseek

Postby ukoenig » Wed Jun 08, 2016 7:52 pm

Silvio,

that returns 3 elements

Code: Select all  Expand view

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 :D
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Problem with dbseek

Postby RAMESHBABU » Thu Jun 09, 2016 2: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
User avatar
RAMESHBABU
 
Posts: 615
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: Problem with dbseek

Postby Silvio.Falconi » Thu Jun 09, 2016 7: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6832
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with dbseek

Postby Silvio.Falconi » Thu Jun 09, 2016 7: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6832
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with dbseek

Postby James Bott » Thu Jun 09, 2016 2: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Problem with dbseek

Postby TimStone » Fri Jun 10, 2016 5: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
User avatar
TimStone
 
Posts: 2905
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 18 guests