Page 1 of 1

Pb 5.11 bug or not ? (ok no bug)

Posted: Fri May 03, 2013 11:43 am
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

Re: Pb 5.11 bug or not ?

Posted: Fri May 03, 2013 11:48 am
by Deeem2031

Code: Select all

read.i a
while a<>0
  ad$=ad$+chr(a)
  read.i a
wend
should do the trick

Re: Pb 5.11 bug or not ?

Posted: Fri May 03, 2013 1:17 pm
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? ;)

Re: Pb 5.11 bug or not ?

Posted: Fri May 03, 2013 1:22 pm
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:

Re: Pb 5.11 bug or not ?

Posted: Fri May 03, 2013 1:36 pm
by MachineCode
Yes, Restore won't change the value of a.

Re: Pb 5.11 bug or not ?

Posted: Fri May 03, 2013 6:16 pm
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