|
Post by Stefan on Jul 23, 2022 8:54:30 GMT -5
Hi George,
I needed a quick way to determine the number of DATA lines in the current file. Now a quick (and dirty) would be numlines = Get_LNum(Get_Last_LPtr-1) It's dirty because if the last line before the 'Bottom of Data' line is a non-Data line, the result is 0.
So I figured that numlines = Get_LNum( Get_Next_LPtr( Get_Last_Lptr,-1,"DATA" ) ) would be just the ticket, i.e " starting at Get_Last_Lptr, go backwards until you find a 'DATA' line " But that also returns a 0 value with RC=8 and Msg=Invalid Get_LNum operand value Drilling down I find that Get_LNum is innocent and it is Get_Next_Lptr which actually lets the side down.
The statement lastDataPtr = Get_Next_LPtr( Get_Last_Lptr,-1,"DATA" ) terminates RC=8, Msg=Invalid starting line pointer argument
I suspect the code kills the request before it evaluates whether or not the search is to go forwards or backwards. I think a backwards search should be allowed.
By the way, the message issued is inconsistent with the reverse dilema when using Get_First_LPtr as the starting point. Using Get_Next_Lptr with a starting point of Get_First_LPtr will allow a forward or backward search and either return a valid result (forward) or RC=8, Msg=Top of file reached (backward)
|
|
|
Post by George on Jul 23, 2022 10:09:50 GMT -5
Stefan: Good deduction. Get_Next_LPtr was validating the LPtr arg against LastLine with a >= rather than just >. Duh!
Corrected.
George
|
|
|
Post by Stefan on Jul 29, 2022 14:09:40 GMT -5
I agree, Robert. But GET_NEXT_LPTR is basically a loop to already do this and will always outperform a coded macro loop. Thx George, Glad you found the hiccup.
|
|