home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Der Mediaplex Sampler - Die 6 von Plex
/
6_v_plex.zip
/
6_v_plex
/
DISK5
/
DOS_34
/
AMAC44.ZIP
/
RFR005.QM
< prev
next >
Wrap
Text File
|
1992-02-16
|
23KB
|
481 lines
* RFR005.QM
* Macros To Count Words And Characters
* Written By Tom Hogshead
* [ See RFRMxx.QM For Use ]
* 2/16/92
* Key Subfile Description
* ===== =============== ====================================================
* @(3) Count Words in a File by John Goodman (Use this)
* @(0) Count Words in a File (Alternate version of @3)
* @(6) Count Words & Characters in File w/COUNT.EXE
* @(4) Count Words in a Block by John Goodman
* @(5) Count Characters In A File INCLUDING Spaces
* @(2) Count Characters in a File EXCLUDING Spaces
* @(1) Count Characters in a Block
*
* @(9) {e:\up\mis002} Add Line Numbers 001 to 999 In Col 1
* @(0) {e:\up\mis002} Add Line Numbers 0001 to 9999 In Col 1
* @(3) {e:\up\mis002} Make File of Numbers 0001 to 9999 Ascending
* @(4) {e:\up\mis002} Make File of Numbers 9999 to 0001 Descending
* @(5) {e:\up\mis002} Make File of Numbers 001 to 999 Ascending
* @(6) {e:\up\mis002} Make File of Numbers 999 to 001 Descending
* @(1) {e:\up\mis002} Add Line Numbers 0001 to 9999 In Col 81
* @(2) {e:\up\mis002} Remove Previous Line Numbers Made With @1
*
* {e:\up\RFRM*}--Return To RFRMxx.QM
* (Calibrated) Test File
* (Timing) Results
*
*-- eoi
*
* --------------------------------------
* @(0) Macro To Count Words In File
* --------------------------------------
* This macro counts the number of words in a File. A word is defined
* as a string of characters contained in either the AltWordSet
* separated by a word delimiter. The number of words in the File equal
* the number of lines in the NUL file after execution.
* Test macro using the calibrated file WORD (41 words).
* [ Number of WORDS in File ] = [ Number of LINES in temp file ]
@0 Macrobegin
AltWordSet
UnMarkBlock
EndLine
Dropanchor
StoreScrBuff "c" Return
BegFile
LOOP:
MarkWord
jfalse 1:
AppendScrBuff "c" Return
1: WordRight
jtrue LOOP:
EditFile "NUL" Return Quit
EditFile Return
GetScrBuff "c" Return
UnMarkBlock
DefaultWordSet
BegFile
DelLine
EndFile
*
* 82 bytes Wed 02-20-1991 16:54:02
* 83 bytes Mon 07-15-1991 11:06:17 (TH @0, changed ! to NUL)
* 45 bytes Wed 08-21-1991 23:55:04 (TH @0)
*
* ----------------------------------------------------------------------
* @(1) Count Number Of Characters In A Block
* ----------------------------------------------------------------------
* To: Mike Butler, RelayNet, May 4, 1991 15:16:09
* MB> Is there any way to create a macro to count the number of
* MB> characters in a block?
* This QEdit macro determines a block's byte size and provides a means
* to calculate the Number of Characters in a block. Block Byte Size can
* be useful for uploading CompuServe files where upload file descriptions
* are limited to 465 bytes:
* Block Byte Size = Size of block if it were a file
* Character Count = (Block Byte Size) minus 2 x (Number of Lines)
* Mark a block. Block need not be closed. Block byte size will be shown in
* a window and in front of the last line of a copy of the block. Press
* <enter> to remove the window from the screen and return to the our
* starting point. To determine the number of actual characters in a block,
* including spaces between text, subtract 2 x (number of lines in window)
* from (byte size). The paragraph below with asterisks is 274 bytes, and
* has 277 - 4 x 2 = 269 characters including spaces and asterisks.
* NOTE: c:temp and c:dir are temporary files created and deleted from the
* disk. Rename files and run QMAC if this causes problems. This macro has
* only been tested with DOS 3.3. SaveFile is used rather than WriteBlock
* in case c:temp and c:dir exist before running.
@1 Macrobegin
Editfile "c:temp" Return * Load temp file
killfile Quit * Kill/quit c:temp
EditFile Return * Load empty c:temp
Copyblock * Copy block to temp file
EndFile DelLine * Delete extra blank line
Savefile * Save temp file to get size
DOS "Dir " Currentfilename * Get DIR list of c:temp
">C:dir" Return Return * Save DIR list of c:temp
Editfile "C:dir" Return * Load DIR list
Gotoline "5" Return * CursorDown to c:temp line
Wordright Markword Copy * Copy size to scrap
Killfile Quit * Kill/quit c:dir
Editfile "c:temp" Return * Load c:temp
Killfile * Kill it
Endfile Begline *
"Block size=" Paste * Paste block size at bottom
Makebotofscreen * Re-position
Pause * Press <enter> to remove block size
Quit * Character Count = Block Size
* minus 2 x Number of Lines
* 114 bytes Sat 05-04-1991 15:15:25
*
* ----------------------------------------------------------------------
* @(2) Count Number Of Characters In A File EXCLUDING Spaces
* ----------------------------------------------------------------------
* This macro counts the number of characters in a file EXCLUDING
* spaces. @5 counts the number of characters in a file INCLUDING
* spaces. The number of characters in a file is calculated by
* subtracting 2 x number of lines in file c:temp from reported byte
* size after macro execution.
@2 Macrobegin
UnMarkBlock * Un-mark all blocks
BegFile Markblockbegin * Mark File
EndFile Markblockend *
Editfile "c:temp" Return * Load empty c:temp
Killfile Quit * Kill/quit c:temp
Editfile Return * Load empty temp file
Copyblock Unmarkblock * Copy File to temp file
Findreplace " " Return * Replace all single spaces
DelLine Return "GN" Return * With Blanks, globally
DELBLANKLINES: *
Begfile * Get to begin of file
CHK4BLANK: *
Endline Begline * Check if line has text
Jtrue NOTBLANK: * If so, go to NOTBLANK
Delline * Or line is blank, delete it
Jtrue CHK4BLANK: * Go check next line
NOTBLANK: *
Endpara *ELSE Move to paragraph end
Cursordown * Move down to next line
Jtrue CHK4BLANK: * If not eof, check again
GETCOUNT: *
Savefile * Save temp file to get size
DOS "DIR " Currentfilename * Get DIR list of c:temp
">C:dir" Return Return * Save DIR list of c:dir
Editfile "C:dir" Return * Load DIR list
Gotoline "5" Return * Cursordown to c:temp line
Wordright Markword Copy * Copy size to scrap
Killfile Quit * Kill/quit c:dir
Editfile "c:temp" Return * Load compressed c:temp
Killfile * Kill c:temp disk copy
Begline "Byte size=" Paste * Paste byte size at bottom
Makebotofscreen * Re-position
Pause * Press <enter> to remove window
Quit * Character Count = Byte Size
* minus 2 x Number of Lines
* 92 bytes Wed 02-20-1991 17:02:29
* 141 bytes Sat 05-04-1991 15:38:07 changed temp file names, added pause
* corrected gotoline "5"
*
* ---------------------------------------------
* @(3) Count Words in File
* Alternate version of @0 by John Goodman
* ---------------------------------------------
* This macro will count the number of words in the current file. A
* word is considered to be a sequence of one or more characters in
* the AltWordSet delimited by at least one character that is not in
* the AltWordSet (this definition should suffice for most
* applications). The number of words in the file is displayed in a
* separate window after they have been counted. When the Enter key
* is pressed, the word count display will be removed and the cursor
* will be positioned at the top of the original file. The macro
* should work consistently regardless of mode toggle or QConfig
* settings and will not change the edit status of the original
* file. The macro does, however, set the word character set to
* DefaultWordSet at the end of the macro.
*
@3 MacroBegin
AltWordSet * Use alternate word character set
UnmarkBlock BegFile * Remove blocks and start at top
OneWindow * Remove any windows
EditFile * Use the NUL file for counting
"NUL" Return
Quit * Make sure NUL file is empty
HorizontalWindow * Create window for counting
EditFile Return * Re-edit the NUL file
DropAnchor * Start a block
"0123456789" * Type digits 0-9
Copy BegLine * Make six copies of digits line
Paste 6
MarkCharacter * Copy the digits w/out EOL char
EndLine Copy
UnmarkBlock
PrevWindow * Return to original file
MAINLOOP: * Loop for each word in file
MarkWord * Test if a word at cursor position
JFalse NEXTWORD: * If not, skip to next word
NextWindow * Go to counting window
EndFile BegLine * Go to ones digit position
INCRLOOP:
DelCh * Delete (increment) the current digit
EndLine * Test if any digits remaining
JTrue INCRDONE:
Paste * Re-paste the 0-9 string
UnmarkBlock
CursorUp * Go to up next significant digit
Jump INCRLOOP: * Increment next significant digit
INCRDONE:
PrevWindow * Return to original file
NEXTWORD:
WordRight * Go to next word right
JTrue MAINLOOP: * If no words to right, display count
BegFile * Return to beginning of original file
NextWindow * Go to count window
BegFile CursorRight * Go to top of 2nd column
MarkColumn * Delete all but column 1
EndLine PageDown
DeleteBlock
JOINLOOP: * Join column 1 into a single line
CursorUp
JFalse PROMPT:
JoinLine
Jump JOINLOOP:
PROMPT:
EndLine * Go to end of count and display prompt
" Words... Press <Enter> to Continue"
Pause * Wait for user to press Enter
Quit CloseWindow * Delete the NUL file and close window
DefaultWordSet * Reset default word set characters
*
* 167 bytes Fri 08-23-1991 21:29:35 (JG @3)
*
* ---------------------------------
* @(4) Count Words in Marked Block
* Written by John Goodman
* ---------------------------------
* This macro will count the number of words in the currently marked
* block. Any type of block may be used and both block end points
* need not be set. A word is considered to be a sequence of one or
* more characters in the AltWordSet delimited by at least one
* character that is not in the AltWordSet (this definition should
* suffice for most applications). The number of words in the block
* is displayed in a separate window after they have been counted.
* When the Enter key is pressed, the word count display will be
* removed and the cursor will be positioned at its original
* location in the file (the original block will be unmarked). The
* macro should work consistently regardless of mode toggle or
* QConfig settings and will not change the edit status of the
* original file. The macro does, however, set the word character
* set to DefaultWordSet at the end of the macro.
*
@4 MacroBegin
AltWordSet * Use alternate word character set
OneWindow * Remove any windows
EditFile * Use the NUL file for counting
"NUL" Return
Quit * Make sure NUL file is empty
HorizontalWindow * Create window for counting
EditFile Return * Re-edit the NUL file
CopyBlock * Copy the block of text to NUL file
JFalse END: * If no block, exit
UnmarkBlock * Unmark the block
SplitLine * Put blank line at top
DropAnchor * Start a block
"0123456789" * Type digits 0-9
Copy BegLine * Make six copies of digits line
Paste 6
MarkCharacter * Copy the digits w/out EOL char
EndLine Copy
UnmarkBlock
BegFile * Go to beginning of text
CursorDown 7
MAINLOOP: * Loop for each word in file
DeleteBlock * Delete the last word processed
MarkWord * Test if a word at cursor position
JFalse NEXTWORD: * If not, skip to next word
CursorUp BegLine * Go to ones digit position
INCRLOOP:
DelCh * Delete (increment) the current digit
EndLine * Test if any digits remaining
JTrue INCRDONE:
Paste * Re-paste the 0-9 string
UnmarkBlock
CursorUp * Go to up next significant digit
Jump INCRLOOP: * Increment next significant digit
INCRDONE:
BegFile * Return to beginning of text
CursorDown CursorDown * Many cursordowns instead of displaying
CursorDown CursorDown * RepeatCmd prompt box many times
CursorDown CursorDown
CursorDown
NEXTWORD:
MarkCharacter * Block last word processed to delete it
WordRight * Go to next word right
JTrue MAINLOOP: * If no words to right, display count
UnmarkBlock
BegFile CursorRight * Go to top of 2nd column
MarkColumn * Delete all but column 1
EndLine PageDown
DeleteBlock
JOINLOOP: * Join column 1 into a single line
CursorUp
JFalse PROMPT:
JoinLine
Jump JOINLOOP:
PROMPT:
EndLine * Go to end of count and display prompt
" Words... Press <Enter> to Continue"
Pause * Wait for user to press Enter
END:
Quit CloseWindow * Delete the NUL file and close window
DefaultWordSet * Reset default word set characters
*
* 183 bytes Fri 08-23-1991 17:45:40 (JG @4)
* (Calibrated) Test File, 41 Words with @0 and @3
* ┌────────────────────────────── WORD ─────────────────────────────────────┐
* │ 1 2 3 │
* │ │
* │ ! @ # $ % ^ & * ' ( ) + | - = \ , . / ; ' [ ] < > ? : " { } │
* │ │
* │ !@#$%^&*'()+|-=\,./;'[]<>?:"{} │
* │ │
* │ 4 5 6 │
* │ 126__Characters 41_Words(W/@0) 41_Words(W/@3) 7 8 9 aa │
* │ │
* │ __ Characters │
* └─────────────────────────────────────────────────────────────────────────┘
*
* ----------------------------------------------------------------------
* @(5) Count Number Of Characters In A File INCLUDING Spaces
* ----------------------------------------------------------------------
* This macro counts the number of characters in a file INCLUDING
* spaces. @2 counts the number of characters in a file EXCLUDING
* spaces. The number of characters in a file is calculated by
* subtracting 2 x number of lines in file c:temp from reported byte
* size after macro execution.
@5 Macrobegin
UnMarkBlock * Un-mark all blocks
BegFile Markblockbegin * Mark File
EndFile Markblockend *
Editfile "c:temp" Return * Load empty c:temp
Killfile Quit * Kill/quit c:temp
Editfile Return * Load empty temp file
Copyblock Unmarkblock * Copy File to temp file
* Findreplace " " Return * Replace all single spaces
* DelLine Return "GN" Return * With Blanks, globally
DELBLANKLINES: *
Begfile * Get to begin of file
CHK4BLANK: *
Endline Begline * Check if line has text
Jtrue NOTBLANK: * If so, go to NOTBLANK
Delline * Or line is blank, delete it
Jtrue CHK4BLANK: * Go check next line
NOTBLANK: *
Endpara *ELSE Move to paragraph end
Cursordown * Move down to next line
Jtrue CHK4BLANK: * If not eof, check again
GETCOUNT: *
Savefile * Save temp file to get size
DOS "DIR " Currentfilename * Get DIR list of c:temp
">C:dir" Return Return * Save DIR list of c:dir
Editfile "C:dir" Return * Load DIR list
Gotoline "5" Return * Cursordown to c:temp line
Wordright Markword Copy * Copy size to scrap
Killfile Quit * Kill/quit c:dir
Editfile "c:temp" Return * Load compressed c:temp
Killfile * Kill c:temp disk copy
Begline "Byte size=" Paste * Paste byte size at bottom
Makebotofscreen * Re-position
Pause * Press <enter> to remove window
Quit * Character Count = Byte Size
* minus 2 x Number of Lines
* 141 bytes Sat 05-04-1991 15:38:07 (TH @2)
* 130 bytes Wed 08-28-1991 00:13:49 (TH @5)
*
* ----------------------------------------------------------------------
* @(6) Count Words and Characters in File Using COUNT.EXE
* ----------------------------------------------------------------------
* This macro counts the number of words and characters in the file
* currently being edited using COUNT.EXE written by Robert Kiesling.
* COUNT.EXE can be found on Exec-PC as COUNT2.ZIP.
@6 macrobegin
savefile
DOS "count " currentfilename return
*
* 20 bytes Thu 08-29-1991 08:58:12 (TH @6)
* (Timing) Results of First 1,000 Words of QEDIT.DOC
* ───────────────────────────────────────────────────-
* Letters Words Chars Lines Blank Seconds
* -------- ----- ----- ----- ----- -------
* COUNT.EXE 1004 7294 175 1.43
* RWC.EXE 6940 1002 175 48 2.36
* WC.EXE 1008 7119 175 2.80
* @5 (TH) 6944 4.3 - spaces counted
* @2 (TH) 5571 6.2 - spaces not counted
* @3 (JG) 1000 41.6 <- Best Macro to use
* @4 (JG) 1000 105.4
* @0 (TH) 1000 108.2
* (JG) John Goodman, author
* The above timing results are reported for the first 1,000 words of
* the QEdit Reference Manual, QEDIT.DOC, v2.1 dated February 1990, 175
* lines, included with the Shareware version. The 1,000th word is
* 'use' on line 175. This 1,000 word portion of QEDIT.DOC is included
* in AMACxx.ZIP as file 'word1k'. Timing measurements reported to two
* decimal places were measured with TIMER.EXE dated 11/10/85. Timing
* measurements reported to one decimal place were measured using a
* stopwatch.
* As can be seen from these timing results, COUNT.EXE appears to be the
* fastest and most versatile program. It can be found on Exec-PC as
* COUNT2.ZIP. The fact that COUNT.EXE counts 4 more words than @0, @3
* or @4 must be attributable to different definitions of 'words'. Of
* the macros to count words, John Goodman's @3 is by far the fastest
* and should be the macro of choice for this purpose. Thanks John for
* this superb job of macro programming.
* Although the character counts are 'close' comparing COUNT.EXE,
* WC.EXE, and @5, these differences must also be attributed to
* different definitions of 'characters' and/or counting techniques:
* @5: 7204 bytes - 2 x 130 lines = 6944 chars
* @3: 5831 bytes - 2 x 130 lines = 5571 chars
* COUNT.EXE appears the program to use based on speed. Preferred use
* of @2 or @5 depends user on requirements. Note COUNT.EXE byte count
* of characters is 175 more than with WC.EXE possibly because COUNT.EXE
* counts the 175 eol characters inserted by QEdit and WC.EXE does not.
* COUNT.EXE character count is the byte size of the file counted.
* As a point of interest, following is the timed output using COUNT.EXE
* on the file QEDIT.DOC:
* Volume in drive E is Seagate 1
* Directory of E:\QE
* QEDIT DOC 244279 4-03-90 2:10a
* 1 File(s) 3393536 bytes free
* Executing E:\COMMAND.COM/c count E:\QE\QEDIT.DOC
* Count (c)1987 Robert Kiesling. All rights reserved
* Counting E:\QE\QEDIT.DOC
* Characters: 244279
* Words: 32569
* Lines: 6253
* [E:\COMMAND.COM/c count E:\QE\QEDIT.DOC]
* Start: 08/28/1991 - 02:53:42.44
* Stop: 08/28/1991 - 02:54:03.47
* Elapsed time: 0 hours, 0 minutes, 21.03 seconds.