Page 1 of 2

replace a record in a file

Posted: Mon Aug 17, 2020 3:32 pm
by tomtagaris
can someone tell me why suddenly i can not replace a record in an file , like this ,not work - replace mark with markreplace-

Re: replace a record in a file

Posted: Tue Aug 18, 2020 10:45 am
by mol
put some code - is it exclusibe mode or share mode? what's the error?

Re: replace a record in a file

Posted: Tue Aug 18, 2020 3:50 pm
by franco
I think this is what your asking.
I found at times if I use a msgbox or msginfo while on a record right after I have to use command with table name in it.
replace table->mark with marketplace.
If mark is a variable you can not use replace. Use equals.
mark := table->marketplace or mark := marketplace.

Re: replace a record in a file

Posted: Wed Aug 19, 2020 5:35 am
by mol
You can use such a statement

Code: Select all

Table->(rlock())
Table->marketplace := market
Table->(dbrunlock())

Re: replace a record in a file

Posted: Wed Aug 19, 2020 8:49 am
by tomtagaris
the problem is at the end of the file after BEGIN SEQUENCE WITH {|o| break(o)} , I place it at the beginning of the work
the append blank working don working the Replace

For i=1 TO Len( hResponse )

Select 2
seek hResponse["invoiceMark"]
if found()
msgbox('Υπάρχει ο Mark')
replace MarkReques with hResponse["invoiceMark"]
skip
else
msgbox('Δέν υπάρχει o Mark',hResponse["invoiceMark"] )
append blank
2-> MARKREQUES := hResponse["invoiceMark"]
replace u_id with hResponse["invoiceUid"]
COMMIT

EndIf
Next i

Re: replace a record in a file

Posted: Wed Aug 19, 2020 10:12 am
by mol
Try to comment Begin sequence - you will see immediately what is the source of error.
Did you set EXCLUSIVE to .T.?
You don't use record locking in this code

Re: replace a record in a file

Posted: Wed Aug 19, 2020 3:36 pm
by franco
IF 2 IS USED SHARED I WOULD

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
IF RLOCK()
replace MarkReques with hResponse["invoiceMark"]
UNLOCK
ENDIF
skip
else
msgbox('Δέν υπάρχει o Mark',hResponse["invoiceMark"] )
SELECT 2
append blank //FRANCO APPEND BLANK LOCKS RECORD
**** 2-> MARKREQUES := hResponse["invoiceMark"]
REPLACE MARKREQUES WITH hResponse["invoiceMark"]
replace u_id with hResponse["invoiceUid"]
UNLOCK
COMMIT

EndIf
SELECT hResponce
Next i

Re: replace a record in a file

Posted: Wed Aug 19, 2020 3:43 pm
by tomtagaris
the problem is for - next
Without for - next the record replaces
I do not understand

Re: replace a record in a file

Posted: Wed Aug 19, 2020 4:03 pm
by franco
Look at above sample
I added select the first file before the next
I think I would use a do while loop instead of for next
SELECT FILE1
GO TOP
DO WHILE ! EOF()
SELECT FILE1
HRESPONCE
SELECT FILE2
AND SO ON
SELECT FILE1
SKIP
LOOP
ENDDO

Re: replace a record in a file

Posted: Wed Aug 19, 2020 4:36 pm
by tomtagaris
It did not work
The problem is in the for next
If I put it for 1 to 2 then it is ok


Select 2

For i=1 TO 2

Replace MARKREQUES with 'samone'
replace u_id with kalavrita'
COMMIT

Next i