Maple Professional
Maple Academic
Maple Student Edition
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professional
MapleSim Academic
Maple T.A. - Testing & Assessment
Maple T.A. MAA Placement Test Suite
Möbius - Online Courseware
Machine Design / Industrial Automation
Aerospace
Vehicle Engineering
Robotics
Power Industries
System Simulation and Analysis
Model development for HIL
Plant Modeling for Control Design
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematics Education
Engineering Education
High Schools & Two-Year Colleges
Testing & Assessment
Students
Financial Modeling
Operations Research
High Performance Computing
Physics
Live Webinars
Recorded Webinars
Upcoming Events
MaplePrimes
Maplesoft Blog
Maplesoft Membership
Maple Ambassador Program
MapleCloud
Technical Whitepapers
E-Mail Newsletters
Maple Books
Math Matters
Application Center
MapleSim Model Gallery
User Case Studies
Exploring Engineering Fundamentals
Teaching Concepts with Maple
Maplesoft Welcome Center
Teacher Resource Center
Student Help Center
FileTools[Text][CountCharacters] - count the occurrences of a character in a file or count the total number of characters in a file
Calling Sequence
CountCharacters(file)
CountCharacters(file, character)
Parameters
file
-
file descriptor or filename
character
string of length 1; character to count
Description
The CountCharacters(file) command counts the number of characters from file's current position to the end of the file.
The CountCharacters(file, character) command counts the number of occurrences of character from file's current position to the end of the file.
As CountCharacters is a Text function, it counts characters, not bytes. Therefore characters represented as multiple bytes, (like "\\r\\n") are counted as a single character. This means the number of characters in a file can differ from the number of bytes in a file.
An error is raised if file is not a valid descriptor or if the filename does not exist.
Examples
See Also
file, FileTools[Position], FileTools[Remove], FileTools[Text], FileTools[Text][Close], FileTools[Text][CountLines], FileTools[Text][WriteString], IO_errors
Download Help Document