Re: Displaying the contents of a text file

Ian_Wade_G3NRW
 

Svein/Richard

Each of your approaches worked fine. Problem solved. Thank you both.

P.S. I had not realised you could concatenate all the lines into one variable (text$). In the extreme, the length of text$ in my program could be 600 lines x 80 chars/line = 48000 characters. Am I correct in assuming there is no limit to the length of text$ (until you run out of memory) in BB4W 6.00 and later?

--
Ian




***** TS-590 Family Resources Page: http://g3nrw.net/TS-590

On 12/05/2017 06:59, Richard Russell wrote:
On Thu, May 11, 2017 at 02:44 pm, Ian_Wade_G3NRW wrote:

I am trying to display the contents of a 600-line plain text file in
BB4W, in an editbox.

If you have a 'plain text file' (and I am assuming you mean a file that uses CRLF pairs as the line terminations) it is quite unnecessary to split it into its constituent lines before sending it to the edit control. It is simpler and quicker to keep it as a single 'unit':

file% = OPENIN("file.txt")
text$ = GET$#file% BY EXT#file%
CLOSE #file%
SYS "SetDlgItemText", !dlg%, 100, text$

It would only be necessary to split it into individual lines if you needed to change the line terminations from (say) LF to CRLF, i.e. it was a Linux-style text file.

The style bit for read-only is ES_READONLY

Richard.


Join bb4w@groups.io to automatically receive all group messages.