Hello,
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
Haim
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.
Barney
Barney,
I tried Dstring dimensioned to more than 255, but it crashed
Haim
Show us the code.
Haim,
Below is some code I have used to read a text file into my program:
TabDlg::LoadHelpText()
{
dstring helptext[6595];
unsigned int hFile = OpenFile(GetStartPath()+"HelpText.txt", MODE_READ);
if(hFile)
{
Read( hFile, helptext, len(byte)*6595 );
m_help_txt->SetText( helptext );
}
return true;
}
Hello,
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
{
readstring(hfile,s,280);
print(s);
closefile(hfile);
}
I fixed it by chnging
dstring s[300] to dstring s[500];
Why does this work???