|
Line counting in WP for Windows
WordPerfect for Windows versions 6.1, 7.0, and 8.0 all have the capability to count lines by accessing the document properties as Word97 does. But WP's document properties don't include spaces or formatting codes. Also WP's line properties count all the lines in the document, even the blank ones. Fortunately for us this is a limitation that is easily sidestepped.
Gross line counting in WordPerfect 8
Below is a gross line count macro for WP8:
PosDocBottom EnterKey Type("@")
PosDocVeryTop PosLineBeg
ASSIGN(VAR1; 0)
LABEL(LOOP)
IF(?RightChar = "")
PosLineDown
ELSE
ASSIGN(VAR1; VAR1+1)
PosLineDown
ENDIF
IF(?RightChar = "@")
DeleteCharNext DeleteCharPrevious PosDocVeryTop
GO(PROMPT)
ELSE
GO(LOOP)
ENDIF
LABEL(PROMPT)
PROMPT("There are " + VAR1 + " LINES in the document")
Pause
PosDocBottom
The gross line count macro for WP8 is very similar to that of WP51. There are slight differences in formatting and some of the commands have changed. For instance, we see PosDocBottom instead of {Home}{Home}{Home}{Down} and IF(?RightChar = "@") instead of {IF}"{SYSTEM}RIGHT~"="@"~. Other than these minor differences the two macros are identical in their function and operation.
There is one major difference in line 5 of the WP8 gross line counter and the WP51 macro. There is no {Enter} or its equivalent EnterKey in this line. The reason is because WordPerfect 8 tests the character to the right of the insertion point and only registers as a true condition if that character is a printable character. Because of this lines starting with Hard Returns and Tabs will not be counted even though they may have text on them. You can circumvent this difficulty by placing one or two spaces at the beginning of the lines you want the macro to count.
Character counting in WordPerfect 8
Here is a character counter for WP8:
PosDocBottom EnterKey Type("@")
PosDocVeryTop PosLineBeg
ASSIGN(VAR1; 0)
LABEL(LOOP)
PosCharNext
ASSIGN(VAR1; VAR1+1)
IF(?RightChar = "@")
DeleteCharNext DeleteCharPrevious PosDocVeryTop
GO(PROMPT)
ELSE
GO(LOOP)
ENDIF
LABEL(PROMPT)
Assign(VAR1; VAR1/65)
PROMPT("There are " + VAR1 + " LINES in the document")
Pause
PosDocBottom
This macro, like its WP51 counterpart, goes to the very top of the document and starts counting how many times it moves to the right. In this way it collects the total number of characters and then divides them by 65. As always, you can replace 65 with the number of characters you normally use per line.
Copyright 1999 by Mike DeTuri (reprinted from Computer Solutions Vol. 1, Issue 2)
|