Error in nextbasic

The Speccy's spritely young offspring. Discuss everything from FPGA to ZX
Post Reply
funkheld
Dizzy
Posts: 55
Joined: Tue May 18, 2021 9:01 pm

Error in nextbasic

Post by funkheld »

Hi good afternoon.
why does this error come up in nextbasic please?

Thank you.
greeting
Image
funkheld
Dizzy
Posts: 55
Joined: Tue May 18, 2021 9:01 pm

Re: Error in nextbasic

Post by funkheld »

I'm looking for a demo that works with bank and peek in nextbasic.

not funktion :
1050 b=b+1 : a= bank 15 peek b

thanks
greeting
User avatar
Pobulous
Dynamite Dan
Posts: 1384
Joined: Wed Nov 15, 2017 12:51 pm

Re: Error in nextbasic

Post by Pobulous »

Has NextBasic done away with the need to use LET for variable assignment?
funkheld
Dizzy
Posts: 55
Joined: Tue May 18, 2021 9:01 pm

Re: Error in nextbasic

Post by funkheld »

hello , this is ok.

now the x doesn't count in the peek.

greeting

Code: Select all

10 RUN AT 3
45 load "daten.map" bank 20
48 let b=0 : let a=0 : let x=0
50 for x=0 to 12
60 let a=% bank 20 peek x : print a 
70 next x
90 go to 90

greeting
szerman
Drutt
Posts: 12
Joined: Sat May 28, 2022 6:53 am

Re: Error in nextbasic

Post by szerman »

I am no expert but try

10 RUN AT 3
45 load "daten.map" bank 20
48 %b=0 : %a=0 : %x=0
50 for %x=0 to 12
60 let a=% bank 20 peek x : print %a
70 next %x

It is all down to the fact let a=% bank 20 peek x is declaired % so the output vairable needs the % to display correctly I think
funkheld
Dizzy
Posts: 55
Joined: Tue May 18, 2021 9:01 pm

Re: Error in nextbasic

Post by funkheld »

thanks for the information.

unfortunately that doesn't work either.

greeting
SNG
Drutt
Posts: 13
Joined: Sat Dec 23, 2023 12:16 am

Re: Error in nextbasic

Post by SNG »

The suggestion fixed one error, the use of x in an integer context when %x was required, but introduced another of the same type.

60 let %a=% bank 20 peek x : print %a

Now you are assigning to %a so printing it makes sense. Alternative fix:

60 let a=% bank 20 peek x : print a

Or cut out the middle-man:

60 PRINT % bank 20 peek x

The great majority of discussion and support for NextBASIC is in the Facebook group BASIC on the ZX Spectrum Next. See you there?
SNG
Drutt
Posts: 13
Joined: Sat Dec 23, 2023 12:16 am

Re: Error in nextbasic

Post by SNG »

Line 48 is entirely redundant and can safely be omitted, BTW.

Incidentally the title is misleading. There is no error in nextBASIC shown here, just one common beginner misunderstanding about the meaning and purpose of % there. I have explained that more fully in another reply here.

I think a lot of people are initially confused because they think the % belongs to a variable rather than the whole expression it prefixes. This may be because they’ve been exposed to the different and relatively useless use of % as a suffix in Microsoft BASIC. The performance and memory benefit of integer expressions in NextBASIC is several times greater, and grows with increasing program size.
Post Reply