Page 1 of 1

Program freezes

Posted: Sun Jul 01, 2018 12:12 am
by dna
I hope I'm offending anyone but, this code:

[code]FH1=OpenFile(FP$):FH2=WriteFile(FQ$)

While Not Eof(FH1)

BT=ReadByte(FH1)
Repeat

AW$=AW$+Chr$(BT):BT=ReadByte(FH1)
Until BT=32
WriteLine(FH2,AW$):AW$="":NW=NW+1
Wend
Print NW+" WRITTEN"[/code]

reads a file a byte at a time. When a space separator is found it then writes the word to another file.
About or near the 100,000th word, the program then freezes.
I know some of you will write that I'm on the forum however some of you are familiar with this.

Re: Program freezes

Posted: Sun Jul 01, 2018 5:03 am
by Josh
About which programming language are you speaking? Maybe it's better you post your question in a forum of your programming language. Use next time correct tags for your posts.

P.S.: Please can any mod move this topic to 'OffTopic'

Re: Program freezes

Posted: Sun Jul 01, 2018 10:15 am
by infratec
If your file does not ends with a space ...
You need an additional eof()

Program freezes

Posted: Sun Jul 01, 2018 10:08 pm
by dna
Thanks

That was it infratec.

The program was also reading past the end of file returning zeros.

Re: Program freezes

Posted: Mon Jul 02, 2018 1:28 am
by oreopa
dna wrote:I hope I'm offending anyone
That (mis)phrase has made my day ;)

Re: Program freezes

Posted: Mon Jul 02, 2018 3:35 am
by Fangbeast
oreopa wrote:
dna wrote:I hope I'm offending anyone
That (mis)phrase has made my day ;)
You know, I read that phrase 3 times and didn't 'see' it till you mentioned it? Must be getting old.

Re: Program freezes

Posted: Mon Jul 02, 2018 8:28 am
by Dude
Fangbeast wrote:You know, I read that phrase 3 times and didn't 'see' it till you mentioned it? Must be getting old.
I read the source code several times without realising it's not even PureBasic, and I wondered why Josh was asking what language it was. :shock: