June 24, 2024, 12:36:07 AM


IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!

Text file question

Started by Haim, November 19, 2007, 05:29:48 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


I have a text file with strings that may be longer than 255 characters.
How can I read the file?
Readstring with maxbytes >255 crashes!

Help please



This is taken from the help file:

STRING - A string of characters up to a length of 255
DSTRING - A dimensionable string that can contain any number of characters.
WSTRING - A unicode string up to a lnegth of 255 characters.
DWSTRING - A dimensionable unicode string that can contain any number of characters.



I tried Dstring dimensioned to more than 255, but it crashed


Bruce Peaslee

Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

John S

Below is some code I have used to read a text file into my program:

dstring helptext[6595];
unsigned int hFile = OpenFile(GetStartPath()+"HelpText.txt", MODE_READ);
Read( hFile, helptext, len(byte)*6595 );
m_help_txt->SetText( helptext );
return true;
John Siino, Advanced Engineering Services and Software


November 19, 2007, 11:14:43 AM #5 Last Edit: November 19, 2007, 11:23:16 AM by Haim
Thank you all for your responses.
I was trying to read a text file with lines of varying length, so I had to use somethig like readstring() and not read() which requires a size parameter.

I am still puzzling over it... :-[

Just fixed it but I do not understand why.

This crashed the program:

uint hfile=openfile("C:\program files\aurora\examples\ur\ITD UR OCTOBER 2007.csv",mode_read);
dstring s[300];
if hfile

I fixed it by chnging
dstring s[300] to dstring s[500];

Why does this work???