Page 2 of 2

Re: replace a record in a file

Posted: Wed Aug 19, 2020 5:31 pm
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.

Re: replace a record in a file

Posted: Wed Aug 19, 2020 6:39 pm
by Carlos Britos
Hi,
I think you have to check the len( hResponse ) and each item of the hash hResponse before the for next

Re: replace a record in a file

Posted: Wed Aug 19, 2020 10:37 pm
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

Re: replace a record in a file

Posted: Thu Aug 20, 2020 6:10 am
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()

Re: replace a record in a file

Posted: Thu Aug 20, 2020 11:36 am
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

Re: replace a record in a file

Posted: Thu Aug 20, 2020 3:13 pm
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.