Created On: 22 December 2011
Problem:
When workeing with Indexed Files in RM COBOL we use the following syntax:
But it doesn't work with Visual COBOLl. How can the first or last record of a particular key be read in Visual COBOL?
START TEST-FILE KEY FIRST KEY-1
or
START TEST-FILE KEY LAST KEY-1
But it doesn't work with Visual COBOLl. How can the first or last record of a particular key be read in Visual COBOL?
Resolution:
This syntax is not supported in Visual COBOL. To get the same functionality you would need to do something like the following:
MOVE LOW-VALUES TO KEY-1
START TEST-FILE KEY >= KEY-1
READ TEST-FILE NEXT RECORD
MOVE HIGH-VALUES TO KEY-1
START TEST-FILE KEY <= KEY-1
READ TEST-FILE PREVIOUS RECORD
MOVE LOW-VALUES TO KEY-1
START TEST-FILE KEY >= KEY-1
READ TEST-FILE NEXT RECORD
MOVE HIGH-VALUES TO KEY-1
START TEST-FILE KEY <= KEY-1
READ TEST-FILE PREVIOUS RECORD