IonicWind Software

Aurora Compiler => Coding Help - Aurora 101 => Topic started by: Haim on November 19, 2007, 05:29:48 AM

Title: Text file question
Post by: Haim on November 19, 2007, 05:29:48 AM
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
Title: Re: Text file question
Post by: Barney on November 19, 2007, 06:32:01 AM
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
Title: Re: Text file question
Post by: Haim on November 19, 2007, 06:45:35 AM
Barney,
I tried Dstring dimensioned to more than 255, but it crashed

Haim
Title: Re: Text file question
Post by: Bruce Peaslee on November 19, 2007, 09:57:26 AM
Show us the code.
Title: Re: Text file question
Post by: John S on November 19, 2007, 10:51:22 AM
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;
}
Title: Re: Text file question
Post by: Haim on November 19, 2007, 11:14:43 AM
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???