Suppose all records are selected and a procedure executes a selectreverse statement. Nothing will happen to the selection. What will be the value of info(“empty”) be in that case? You might think that since nothing was selected by selectreverse statement, that info(“empty”) would have a value of -1, i.e., true. But it does not. It has a value of 0.
So code that has a selectreverse followed by if info(“empty”) code could lead to an unexpected result. It did in in my case and it took me a long time to figure out what was happening. I fixed the problem by replace the lines
selectreverse
if not info("empty")
with
selectreverse
if info("selected")<info("records")
//this finds out if selectreverse selected something less that all records
if info("selected")<info("records")
selectreverse
endif
While I was in there, I also made selectreverse work properly with any previous failed selection. If the previous selection failed (zero records selected), selectreverse will now select all records (the reverse of zero). If you wanted to do that now, you would have to use this code:
if info("empty")
selectall
else
selectreverse
endif
So you might want to combine these two fixes:
if info("empty")
selectall
else
if info("selected")<info("records")
selectreverse
endif
endif