Page 1 of 1

Posted: Wed Mar 13, 2002 5:47 pm
by BackupUser
Restored from previous forum. Originally posted by rdenkers.

Ok, here we go.
I want to read a sequential file til the end of the file.
It must be read into a string so it can be displayed in a textbox.
Yes i admit, im only programming for 2 days in PB.
And my ( cobol) background doesnt really help me out here

the reference manual is not helping me very much to figure it out.

Anyone a good idea?
TIA.
rick




"Mensen struikelen niet over bergen, maar over molshopen."
Confucius

Posted: Thu Mar 14, 2002 1:47 am
by BackupUser
Restored from previous forum. Originally posted by PB.

> I want to read a sequential file til the end of the file.
> It must be read into a string so it can be displayed in a textbox.

Here you go:

Code: Select all

f$=OpenFileRequester("Select file to read","","All files (*.*)|*.*",0)
If ReadFile(0,f$)=0
  MessageRequester("Error","Couldn't read "+GetFilePart(f$),0)
Else
  While Eof(0)=0 ; Read each line until Eof (end-of-file).
    a$=ReadString() ; Read the next sequential line in the file.
    v$=v$+a$+Chr(13) ; Add it to v$ with a carriage-return [Chr(13)].
  Wend
  CloseFile(0)
  MessageRequester("File contents",v$,0)
EndIf

PB - Registered PureBasic Coder

Edited by - PB on 14 March 2002 01:49:26

Posted: Thu Mar 14, 2002 6:36 am
by BackupUser
Restored from previous forum. Originally posted by rdenkers.

Pb,
Thanks for your assistance.
It works fine.

Rick


"Mensen struikelen niet over bergen, maar over molshopen."
Confucius