V119 not merging sort file (OpenInsight Specific)
At 04 FEB 1998 05:19:33AM Dom Glennon wrote:
I'm having difficulty getting V119 to merge the external sort file and then read the results in. When I read the results (using Function code 'V' in a loop), they are in sorted blocks just as if the merge call never had any effect. Also, it reads in far more (at least twice as much) as I wrote. The sort record contains a word and three numbers, all of which are sorted on, plus a string of characters (which may contain \00\) as satellite data. The file is empty at the start of the operation.
Here's the basic code (somewhat simplified):
V119("I", SORT.FILE$, "", "", "", Flag)
IF Flag ELSE Debug
Bys=AAAA"
Justs=LRRR"
LOOP
GOSUB CREATE_SORTBLOCKWHILE LEN(SortBlock)
Remove trailing @RMSortBlock-1,1="
Sort and write to C:\SORT.DATV119("S", "", Bys, Justs, SortBlock, "")V119("W", SORT.FILE$, "", "", SortBlock, Flag)IF Flag ELSE DEBUGSortBlock="REPEAT
IF LEN(SortBlock) THEN
SortBlock-1,1="
Sort remaining dataV119("S", "", Bys, Justs, SortBlock, "")
Write sorted block to DOS fileV119("W", SORT.FILE$, "", "", SortBlock, Flag)IF Flag ELSE DEBUGEND
* Merge sorted block
V119("M", SORT.FILE$, Bys, Justs, "", Flag)
IF Flag ELSE DEBUG
* Read sorted file in in 32K blocks
V119("V", SORT.FILE$, "", "", SortBlock, Flag)
IF Flag ELSE DEBUG
SortBlock-1,1="
BlockLen=LEN(SortBlock)
LastWord="
LOOP
WHILE BlockLen
SortRec=SortBlockSpos, @RMSpos=Col2()+1ThisWord=SortRec1, @FMThisPos=SortRecCol2()+1, @FMSearchWordNum=SortRecCol2()+1, @FMOffset=SortRecCol2()+1, @FMCiteInfo=SortRecCol2()+1, @FMIF ThisWord # LastWord THENGOSUB PROCESS_WORDLastWord=ThisWordEND ELSEGOSUB ADD_TO_STATISTICSENDIF Spos ] BlockLen THEN
Read another blockV119("V", SORT.FILE$, "", "", SortBlock, Flag)IF Flag ELSE DEBUGSortBlock-1,1="Spos=1BlockLen=LEN(SortBlock)ENDREPEAT
Many thanks for your time of you can help me on this one.
Dom Glennon
Cambridge University Press
At 04 FEB 1998 07:13AM Dom Glennon wrote:
It's okay - the problem was in removing the trailing @RM from the sort block before writing to the file.
Dom