Program freezes

Just starting out? Need help? Post your questions and find answers here.
dna
User
User
Posts: 83
Joined: Wed Aug 30, 2006 12:07 am

Program freezes

Post 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.
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Program freezes

Post 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'
sorry for my bad english
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Program freezes

Post by infratec »

If your file does not ends with a space ...
You need an additional eof()
dna
User
User
Posts: 83
Joined: Wed Aug 30, 2006 12:07 am

Program freezes

Post by dna »

Thanks

That was it infratec.

The program was also reading past the end of file returning zeros.
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 283
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: Program freezes

Post by oreopa »

dna wrote:I hope I'm offending anyone
That (mis)phrase has made my day ;)
Proud supporter of PB! * Musician * C64/6502 Freak
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Program freezes

Post 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.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Program freezes

Post 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:
Post Reply