// command wc(): Display on the message line,
// the total numbers of characters, words and
// lines in the current file.
//
// This ubiquitous procedure has been done ad
// infinitum by many developers. It's almost
// as common as Hello World! I don't presume
// to hold any claim to it.
//
// On a large file of several thousand lines
// or more, it can take a few seconds to
// display its results
_command wc() {
cc = 0; // character count
wc = 0; // word count
lc = 0; // line count
item = 0;
_save_pos2(p);
top_of_buffer();
for (;;) {
get_line line;
lc++;
for (i = 1; i < length(line); i++) {
cc++;
if (isalnum(substr(line,i,1))) {
item = 1;
} else if (item && !isalnum(substr(line,i,1))) {
wc++;
item = 0;
}
}
status=down();
if (status == BOTTOM_OF_FILE_RC) {
message("chars: " cc " / words: " wc " / lines: " lc);
break;
}
}
_restore_pos2(p);
}
October 29, 2009 at 12:51 PM
Nice. I prefer the unix wc(1) order of lines / words / characters, for consistency.
October 12, 2015 at 5:35 PM
This content is written very well. Your use of when making your points makes your observations very clear and easy to understand. Thank you.
character count tool
June 13, 2019 at 4:56 AM
This post is so nice. I will share this blog. I hope please keep sharing this type of blog !
Word Count Software