Post by NewbieThanks for your replies.!
I have closed the file and then the program reopens it. And yes, I am
using position GPC to point to the 1st record position using 0d as the
position. I am reading the file using readlock GPC but the record it
reads is the one on which the file was closed.
Also, is it possible to read the file in reverse order in TAL?
-Sjay
What you describe the program as doing is what it should do to make the first read after the reopen get the first record. Actually, you do not need to make a positioning call, but explicitly setting the position to record 0 should not hurt. The program probably has an error in it which is making it not do what you are describing that it does. If after looking at the program carefully and/or examining its execution in the debugger, you cannot find the problem, you probably will have to show us the code.
If the program is large or if confidentiality prevents you from showing the code of the real program, you ought to be able to build a test program by extracting just the relevant procedure calls into a new source program, then filling in just enough variable declarations and initializations to permit it to compile and run. The relevant procedure calls, assuming I understand the program correctly from your descriptions, would be:
the first open of the file
any position and/or read calls
the close of the file
the reopen of the file
the position of the file to record 0
the read of the file
Get that test program to compile, run, and be sure it demonstrates the problem, then post it for us to examine.
Also, please explain how you know that the record that the last read gets is not the true first record of the file.
As for your new question: Yes, it is possible to read in reverse order. You must use the KEYPOSITION or FILE_SETKEY_ procedure to do so, since the option does not exist in the POSITION or FILE_SETPOSITION_ procedures. It is possible to position a relative file using KEYPOSTION and FILE_SETKEY_.
Reverse read is requested by setting bit 1 of the positioning-mode parameter to KEYPOSITION or bit 1 of the options parameter to FILE_SETKEY_. For either procedure, you would specify 0 for the keyspecifier parameter. For KEYPOSITION, you would specify a key-value parameter of four bytes each containing 0, with 4 specified in the lengh-word parameter. For FILE_SETKEY_ you would specify a key-value parameter of eight bytes each containing 0, with 8 specified in the key-value-len parameter. Read the full description of the procedure you choose to use from the Guardian Procedure Calls Reference Manual to be sure you understand all the parameters and considerations. If you have questions about how to use it, we will be happy to answer them here.