Post by Stefan on Jan 1, 2024 10:37:16 GMT -5
George,
I apologise for opening the new year with a potentially nasty one to hunt down. I'm almost hoping this is user-error, but I fear it isn't.
A FIND <search-str> PREV command, where <search-str> is a regular expression, appears to start its search from the wrong line.
Note: Command arguments NEXT, FIRST, LAST are not affected.
I spotted the error with the LISTPROC.MACRO with which you are familiar.
I've boiled down the test scenario and the RegEx to bare bones to eliminated everything other than the use of RegEx.
The FIND command below places the cursor at the PREVIOUS line which
- starts in col 1 (^) with one or more Word characters (\w+), followed by a colon and a blank (\: )
FIND R`^\w+\: ` PREV
Bit of test data, it's pupose is irrelevant.
000001 ANOTHER: PROCEDURE EXPOSE (dbugVars) (gblVars)
000002 blah
000003 RETURN
000004
000005
000006 IsNumOK: PROCEDURE EXPOSE (dbugVars) (gblVars)
000007 IF E.!TraceP THEN E.!PrvL = SigL
000008 ----------------------------------------------------------------------------------------
000019 -- CHECK FOR "GOOD" NUMBER -
000010 ----------------------------------------------------------------------------------------
000011 ARG num
000012 RETURN num~DataType("W") & - /* Ensure it IS indeed a number AND */
000013 ( num > 999 & num < 1960 | - /* ( between 999 and 1960 ) OR */
000014 num > G.!Year ) /* higher than current year ) */
000015
1) Copy/Paste the sample data into an edit session
2) Copy/Paste the FIND command to the Primary command line
3) Position the cursor on any line AFTER line number 000007
4) Hit ENTER
The Find command will correctly pick out line 000006 with the cursor on 'IsNumOK'
5) RETRIEVE or Copy/Paste the FIND command to the Primary command line again
6) Position the cursor anywhere ON line number 000007 - ie the line immediately after the "IsNumOK" line.
7) Hit Enter
The Find command will INCORRECTLY pick out line 000001 with the cursor on 'ANOTHER'
Repeat the above steps with a precise search, using FIND R`^\QisNumOK: \E` PREV
(as before but the \Q...\E sequence forces a search for the specific string)
Same results, except that obviously it won't pick out "ANOTHER" but issue message 'Top of data reached' instead.
Contrast this specific search with a simple FIND `isNumOK` PREV command, which of course hits the spot every time.