Can you show me the class you are working with at the moment again? I don't see where you are calling string.length.
Matthew Small IT Supervisor Showstopper National Dance Competitions 3660 Old Kings Hwy Murrells Inlet, SC 29576 843-357-1847 http://www.showstopperonline.com -----Original Message----- From: Tiffany Blake [mailto:Tiffany_Blake@;gap.com] Sent: Thursday, October 31, 2002 9:58 AM To: ActiveServerPages Subject: RE: .Net text file stream answer: 1) cs0103: the name 'line' does not exist in class/namespace AND cs1501: no overload method for 'read' takes '2' arguments 2) it doesn't matter if spaces are counted 3) the text file i'm referencing is 1KB reply to comments: - my code includes a StreamReader to read the entire text file into a string FileStream inStream = new FileStream("filestream.txt",FileMode.Open); StreamReader reader = new StreamReader(inStream); //initialize counter for file data rows int linenum = 1; //read file and write contents to console for (string line = reader.ReadLine(); line != null;line = reader.ReadLine(), linenum++) - i received compile errors when i tried to invoke the String.Length function thanks again for your help!! -----Original Message----- From: Matthew Small [mailto:matt6@;showstopperonline.com] Sent: Thursday, October 31, 2002 6:39 AM To: ActiveServerPages Subject: RE: .Net text file stream OK, questions: 1) What is the error that you are getting? 2) Are spaces considered characters? 3) What is the longest text file that will be read? Next, comments: If it's a relatively short text file (I think anything under a million characters is reasonable [1 Mb?], anybody else is welcome to chime in here on this) then I would read the entire text file into one string and then parse it. The way I would parse it is this: 1) Characters are easily counted if spaces are counted as well. String.length(). If spaces are not counted, then either count the number of spaces in the string and substract it from the length or do a string.replace() on the string until all of the spaces have been eliminated. Don't do this until the end so you don't mess up the words. 2) I think that you can consider words to be anything that is between a space. Therefore, the number of words you have is (number of spaces - 1). 3) Sentences should be equal to the number of periods, question marks, and exclaimation points as long as they each have a space after it. Examples: "You're doing what???" = 1 sentence because of the space after the last question mark "I want to go to the fair (the one where Sally won't be there!) and eat popcorn." = 1 sentence because the exclaimation point does not have a space after it. "I think that object.method will work." = 1 sentence Hope it helps. Matthew Small IT Supervisor Showstopper National Dance Competitions 3660 Old Kings Hwy Murrells Inlet, SC 29576 843-357-1847 http://www.showstopperonline.com -----Original Message----- From: Tiffany Blake [mailto:Tiffany_Blake@;gap.com] Sent: Thursday, October 31, 2002 9:28 AM To: ActiveServerPages Subject: RE: .Net text file stream Matthew - thanks for responding... my problem is the code won't compile and i can't figure out how to count chars, words and sentences. i really am a newbie... [EMAIL PROTECTED] -----Original Message----- From: Matthew Small [mailto:matt6@;showstopperonline.com] Sent: Thursday, October 31, 2002 6:20 AM To: ActiveServerPages Subject: RE: .Net text file stream So what exactly is the problem? Is it that you can't figure out how to count sentences, that it doesn't compile, both, or something else? Matthew Small IT Supervisor Showstopper National Dance Competitions 3660 Old Kings Hwy Murrells Inlet, SC 29576 843-357-1847 http://www.showstopperonline.com -----Original Message----- From: Tiffany Blake [mailto:Tiffany_Blake@;gap.com] Sent: Thursday, October 31, 2002 8:58 AM To: ActiveServerPages Subject: .Net text file stream Importance: High sorry - i'm a .net newbie so here goes... - i'm using a text file stream for input - my goal is to output the # of characters, words and sentences - instead of counting # of sentences i counted the # of lines in the file - i have partial solution for characters and words any ideas? here's my code ........ using System; using System.IO; using System.Text; class Class1 { //read a text file to perform string manipulation static void Main(string[] args) { //open text file FileStream inStream = new FileStream("filestream.txt", FileMode.Open); StreamReader reader = new StreamReader(inStream); //initialize counter for file data rows int linenum = 1; //read file and write contents to console for (string line = reader.ReadLine(); line != null;line = reader.ReadLine(), linenum++) Console.WriteLine(line); Console.WriteLine(linenum); // create array to hold all the characters file contents string(line), char[] tbArray = new char[50]; //read string(line) ** HELP ** this is where compile bombs StringReader strReader = new StringReader(line); strReader.Read(tbArray, 0); // Display the output. Console.WriteLine(tbArray); //close file reader.Close(); strReader.Close(); } } ........ thanks and truly greatful (i've been up all nite!) [EMAIL PROTECTED] --- You are currently subscribed to activeserverpages as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% --- You are currently subscribed to activeserverpages as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% --- You are currently subscribed to activeserverpages as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% --- You are currently subscribed to activeserverpages as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% --- You are currently subscribed to activeserverpages as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% --- You are currently subscribed to activeserverpages as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED]
