View previous topic :: View next topic
|
Author |
Message |
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
Hi all,
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
CODE:
Code: |
FILEEDT.
DISPLAY "ENTER THE STUDENT ROLL NO TO EDIT ".
ACCEPT RNO.
READ STD-FILE
KEY IS SROLL
INVALID KEY DISPLAY " INVALID ROLL NO .. ERROR FS : " FS
END-READ.
DISPLAY STD-DET.
DISPLAY "ENTER WHICH FIELD YOU NEED TO EDIT ".
DISPLAY "CODE : 1.ROLLNO, 2.NAME, 3.MARKS ".
ACCEPT FLD.
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 "
END-IF.
DISPLAY SNAME SPACE SROLL SPACE SINIT.
REWRITE STD-DET
INVALID KEY DISPLAY "KEY ERROR !!! " FS
END-REWRITE. |
|
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
Hi all,
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. |
|
Back to top |
|
|
sunnybunny
New User
Joined: 29 Nov 2005 Posts: 49
|
|
|
|
Hi,
But here one thing i didn't understand. A/C to ur solution without reading the record how can we update it? Please clarify it.
Thanks,
Sunny. |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
Sunny,
REWRITE Means READ & WRITE, Hope clear. |
|
Back to top |
|
|
|