replace a record in a file

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
tomtagaris
Posts: 113
Joined: Tue Aug 23, 2016 2:43 pm

replace a record in a file

Post 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-
User avatar
mol
Posts: 3777
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: replace a record in a file

Post by mol »

put some code - is it exclusibe mode or share mode? what's the error?
franco
Posts: 878
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 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.
All The Best,
Franco
Canada
User avatar
mol
Posts: 3777
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: replace a record in a file

Post by mol »

You can use such a statement

Code: Select all

Table->(rlock())
Table->marketplace := market
Table->(dbrunlock())
User avatar
tomtagaris
Posts: 113
Joined: Tue Aug 23, 2016 2:43 pm

Re: replace a record in a file

Post 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
User avatar
mol
Posts: 3777
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: replace a record in a file

Post 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
franco
Posts: 878
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: replace a record in a file

Post 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
Last edited by franco on Wed Aug 19, 2020 5:24 pm, edited 2 times in total.
All The Best,
Franco
Canada
User avatar
tomtagaris
Posts: 113
Joined: Tue Aug 23, 2016 2:43 pm

Re: replace a record in a file

Post by tomtagaris »

the problem is for - next
Without for - next the record replaces
I do not understand
franco
Posts: 878
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: replace a record in a file

Post 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
Last edited by franco on Wed Aug 19, 2020 5:16 pm, edited 1 time in total.
All The Best,
Franco
Canada
User avatar
tomtagaris
Posts: 113
Joined: Tue Aug 23, 2016 2:43 pm

Re: replace a record in a file

Post 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
Post Reply