I was trying to rewrite the existing record in a program. when i follow the below code i faced a logical error. when i enter the roll no as 100 and edit the field , 101 record is been rewritten. like this the record pointer is read and rewriten to the next record. How can i overcome from this error. plz help me
DISPLAY "ENTER THE STUDENT ROLL NO TO EDIT ".
KEY IS SROLL
INVALID KEY DISPLAY " INVALID ROLL NO .. ERROR FS : " FS
DISPLAY "ENTER WHICH FIELD YOU NEED TO EDIT ".
DISPLAY "CODE : 1.ROLLNO, 2.NAME, 3.MARKS ".
IF FLD = 1 DISPLAY "ENTER ROLLNO :" ACCEPT SROLL1
MOVE SROLL1 TO SROLL
ELSE IF FLD = 2 DISPLAY "ENTER NAME : " ACCEPT SNAME1
DISPLAY "ENTER INITIAL : " ACCEPT SINIT1
MOVE SNAME1 TO SNAME
MOVE SINIT1 TO SINIT
ELSE IF FLD = 3 DISPLAY "ENTER MARK1 : " ACCEPT MARK1
DISPLAY "ENTER MARK2 : " ACCEPT MARK2
DISPLAY "ENTER MARK3 : " ACCEPT MARK3
COMPUTE TOTAL1 = MARK1 + MARK2 + MARK3
MOVE MARK1 TO SMARK1
MOVE MARK2 TO SMARK2
MOVE MARK3 TO SMARK3
MOVE TOTAL1 TO STOTAL
ELSE DISPLAY "INVALID CHOICE "
DISPLAY SNAME SPACE SROLL SPACE SINIT.
INVALID KEY DISPLAY "KEY ERROR !!! " FS
I got the solution. Yap. The thing is i used the READ statement at the begining. So that After a read the Record pointer moves to the next record. such that if i try to rewrite it was written to the next record probably. Now once i remove the READ statement at the top the process is moving quite fine. Thanks for all.