Pb 5.11 bug or not ? (ok no bug)

Just starting out? Need help? Post your questions and find answers here.
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Pb 5.11 bug or not ? (ok no bug)

Post by dobro »

with this code, the first part decode the data without problems
but the second part using While-wend only shows me the first character!

what's wrong ... or it kidding? :shock:

Code: Select all

;Decodeur
Restore cod:
repeat
	read.i a
	ad$=ad$+chr(a)
until  a=0
debug ad$ ; jusque la ok !! mais ....

; *******************************************
ad$=""
Restore cod:
while a=0
	read.i a
	ad$=ad$+chr(a)
wend
debug ad$
; ******************************************


DataSection
	cod:
	Data.i 115,105,32,109,97,32,116,97,110,116,101,32,101,110,32,97,118,97,105,101,110,116,44,32,111,110,32,108,39,97,112,112,101,108,101,114,97,105,32,116,111,110,116,111,110,32,33,0
EndDataSection
; 

; EPB
Last edited by dobro on Fri May 03, 2013 1:24 pm, edited 1 time in total.
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
Deeem2031
Enthusiast
Enthusiast
Posts: 216
Joined: Sat Sep 20, 2003 3:57 pm
Location: Germany
Contact:

Re: Pb 5.11 bug or not ?

Post by Deeem2031 »

Code: Select all

read.i a
while a<>0
  ad$=ad$+chr(a)
  read.i a
wend
should do the trick
irc://irc.freenode.org/#purebasic
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Pb 5.11 bug or not ?

Post by MachineCode »

dobro wrote:what's wrong
Nothing. It does exactly what you coded.

At the end of the first loop, a=0, so the start of the second loop gets the new value for a.

Then, a is no longer 0 (it's now 115), so the second loop quits after showing the first character.

What's the bug? ;)
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: Pb 5.11 bug or not ?

Post by dobro »

MachineCode wrote: At the end of the first loop, a=0, so the start of the second loop gets the new value for a.

ha ? and

Code: Select all

Restore cod:
, he is there just to look pretty?

[reedit]

ho I just figured Restore is not Read: :lol:
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Pb 5.11 bug or not ?

Post by MachineCode »

Yes, Restore won't change the value of a.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Pb 5.11 bug or not ?

Post by Demivec »

dobro wrote:

Code: Select all

Restore cod:
This command shouldn't have the ':' on the end of the label name. It is true that PB kindly ignores that thinking you are going to add more commands after the ':'. Even though it ends up finding no more commands on the line it still isn't a good practice to rely on PureBasic to ignore typos. It may come back to haunt you in the future. :shock:

It should just be enetered as:

Code: Select all

Restore cod
Post Reply