473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

StringReader

I am using stringreader to repeat through each line of a
file ,but my string reader is clubbing 4 to 5 lines as
single line at few places, what could be the problem?

Please send me the suggestions

Thank you
Jul 21 '05 #1
4 3141
Hi Vannela,

Are you shure that file lines are delimited with \r, \n, or \r\n?

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"Vannela" <an*******@discussions.microsoft.com> wrote in message
news:07****************************@phx.gbl...
I am using stringreader to repeat through each line of a
file ,but my string reader is clubbing 4 to 5 lines as
single line at few places, what could be the problem?

Please send me the suggestions

Thank you

Jul 21 '05 #2
Vannela <an*******@discussions.microsoft.com> wrote:
I am using stringreader to repeat through each line of a
file ,but my string reader is clubbing 4 to 5 lines as
single line at few places, what could be the problem?


Well, the problem is probably in your code. Please post a short but
complete example program which demonstrates the problem - see
http://www.pobox.com/~skeet/csharp/complete.html for what I mean by
that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3
source string conatins this code:

type cb_ok from commandbutton within
w_cd_review_regulatory_approval
int X=933
int Y=924
int Width=302
int Height=108
int TabOrder=40
boolean Enabled=false
boolean BringToTop=true
string Text="Approve"
boolean Default=true
int TextSize=-10
int Weight=400
string FaceName="Arial"
FontFamily FontFamily=Swiss!
FontPitch FontPitch=Variable!
end type

event
clicked;//*************************************************
*****************
STRING l_Message[]
IF fw_Save() <> c_Success THEN
RETURN
END IF
//---------------------------------------------------------
---------
// Close the window.
//---------------------------------------------------------
---------

Close(PARENT)

//*********************** End of Script ************

end event

type cb_cancel from commandbutton within
w_cd_review_regulatory_approval
int X=1344
int Y=924
int Width=302
int Height=108
int TabOrder=50
boolean BringToTop=true
string Text="Cancel"
boolean Cancel=true
int TextSize=-10
int Weight=400
string FaceName="Arial"
FontFamily FontFamily=Swiss!
FontPitch FontPitch=Variable!
end type

event
clicked;//*************************************************
*****************
i_SaveOnClose = c_CloseNoSave

Close(PARENT)

//*********************** End of Script
****************************

end event

I want to get the string from the match :TYPE (followed by
some word) FROM (followed by some word) till i encounter
another such match. But my problem is in the above source
string which i have given it is matching the below whole
thing as a single line in this way that too only at few
places and with type of code ( as different input it is
working fine) what could be the problem?
Close(PARENT) //*********************** End of Script
**************************** end event type cb_cancel
from commandbutton within w_cd_review_regulatory_approval
int X=1344 int Y=924 int Width=302 int Height=108 int
TabOrder=50 boolean BringToTop=true string Text="Cancel"
boolean Cancel=true int TextSize=-10 int Weight=400
string FaceName="Arial" FontFamily FontFamily=Swiss!
FontPitch FontPitch=Variable! end type event
clicked;//*************************************************
*****************

int v_flag=0;
StringReader v_rdr=new StringReader(source);
for(string v_Wline =v_rdr.ReadLine();v_Wline!
=null;v_Wline=v_rdr.ReadLine())
{
while(v_flag==0)
{

if(Regex.IsMatch
(v_Wline,@"type\s+\w+\s+from\s+"+@"\w+",RegexOptio ns.Ignore
Case))
{
Match v_match =Regex.Match
(v_Wline,@"\w+\s+from\s+",RegexOptions.IgnoreCase) ;

v_tempcode=null;
do
{
v_tempcode+=v_Wline+"\n";
v_Wline=v_rdr.ReadLine();

if(v_Wline==null)
{
v_flag=1;
break;
}
}while(!Regex.IsMatch
(v_Wline,@"type\s+\w+\s+from\s+",RegexOptions.Igno reCase));

}
}

-----Original Message-----
Vannela <an*******@discussions.microsoft.com> wrote:
I am using stringreader to repeat through each line of a file ,but my string reader is clubbing 4 to 5 lines as
single line at few places, what could be the problem?
Well, the problem is probably in your code. Please post a

short butcomplete example program which demonstrates the problem - seehttp://www.pobox.com/~skeet/csharp/complete.html for what I mean bythat.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.

Jul 21 '05 #4
Vannela <an*******@discussions.microsoft.com> wrote:

<snip>
I want to get the string from the match :TYPE (followed by
some word) FROM (followed by some word) till i encounter
another such match. But my problem is in the above source
string which i have given it is matching the below whole
thing as a single line in this way that too only at few
places and with type of code ( as different input it is
working fine) what could be the problem?


I suspect your problem is that you're building up the string with just
"\n"s in instead of full carriage return / line feeds ("\r\n"). I would
also suggest using a StringBuilder instead of string concatenation.

However, you should really go through it line by line with the
debugger, and find out what lines are being *read* each time, to see
whether StringReader really is reading more than one line unexpectedly.
Does your input file perhaps contain a mixture of "\n" and "\r\n"
linebreaks? That shouldn't confuse StringReader, but it might be worht
investigating.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Brian Rogers | last post by:
To whom it may concern: Can anyone explain this behaviour in serialization and deserialization? I serialize an object using an XML serializer. I de-serialize the object from a StringReader and...
3
by: Mike | last post by:
Is it true that these objects are forwardonly? If not, can someone show me how to go back to line 1, after I have read the first 100 lines. Thanks Mike
5
by: Howard Kaikow | last post by:
How does one determine the number of lines before using ReadLine. This would enable the ReDim to be out of the loop. sReader = New StringReader(xxx.GetObjectText_) If Not (sReader Is Nothing)...
2
by: Bryan Dickerson | last post by:
StreamReader says it is designed to read a stream of characters StringReader says it is designed to read a string TextReader says it is designed to read a sequential list of characters. I hate...
4
by: Vannela | last post by:
I am using stringreader to repeat through each line of a file ,but my string reader is clubbing 4 to 5 lines as single line at few places, what could be the problem? Please send me the...
2
by: das | last post by:
hello all, might be a dumb one, I have a StringWriter to which I write some text, after doing this I want to read this into a StringReader so that I can manipulate the data ex:...
1
by: Mike P | last post by:
I am trying to send out an email that is based upon an HTML page. Is it possible to read the HTML page into something like a StringReader and then set the Mail.Body equal to the StringReader? If...
1
by: depalau | last post by:
I'm experiencing issues where XmlSerialier.Deserialize throws an exception when attempting to use a MemoryStream built with an XmlWriter vs. a standalone StringReader. It is attempting to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.