replace a record in a file

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: replace a record in a file

Post by franco »

I changed my sample above. I would suggest to use select TABLENAMES instead of 2.
Try do while loop.
If it does not work I will try to make sample. What is table 2`s name.
All The Best,
Franco
Canada
Carlos Britos
Posts: 245
Joined: Sat Aug 02, 2008 5:03 pm

Re: replace a record in a file

Post by Carlos Britos »

Hi,
I think you have to check the len( hResponse ) and each item of the hash hResponse before the for next
Regards/Saludos, Carlos (bcd12a)
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: replace a record in a file

Post by franco »

I think Carlos is right and skip is in the wrong spot
maybe
local mrec
select hResponse
Mrec := reccount()
go top
for i := 1 to mrec
if
code
endif
select hResponse
skip
next i
All The Best,
Franco
Canada
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: replace a record in a file

Post by mol »

Maybe problem lays in len(hResponse) statement?
Try to replace with len(hb_hKeys(hResponse))

By the way, for what are you searching the same record in the loop:
seek hResponse["invoiceMark"]
if found()
User avatar
tomtagaris
Posts: 107
Joined: Tue Aug 23, 2016 2:43 pm

Re: replace a record in a file

Post by tomtagaris »

Thank you very much
for your response and your valuable help
I solved the problem as follows
if Len( hResponse ) > 1

For i=1 TO Len( hResponse )

Select 2
seek hResponse["invoiceMark"]
if found()
msgbox('Υπάρχει ο Mark') //Franco I have trouble here so i RESELECT TABLE AFTER MSGBOX
SELECT 2

replace MarkReques with hResponse["invoiceMark"]

ENDIF
skip
else
msgbox('Δέν υπάρχει o Mark', hResponse["invoiceMark"] )
SELECT 2

REPLACE MARKREQUES WITH Val(hResponse["invoiceMark"])
replace u_id with hResponse["invoiceUid"]
COMMIT

EndIf

Next i

else
SELECT 2
// append blank //FRANCO APPEND BLANK LOCKS RECORD
**** 2-> MARKREQUES := hResponse["invoiceMark"]
REPLACE MARKREQUES WITH Val(hResponse[1]["invoiceMark"])
replace u_id with hResponse[1]["invoiceUid"]
Replace Success with hResponse[1]["statusCode"]
COMMIT

EndIf
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: replace a record in a file

Post by franco »

I am glad you got it working.
For what you are doing I think i would use related tables. It would be a lot less code.
All The Best,
Franco
Canada
Post Reply