Passing array to procedure in BBC Basic(Z80)?

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
Neurox66
Posts: 2
Joined: Fri 03 Feb 2023, 17:59

Passing array to procedure in BBC Basic(Z80)?

Post by Neurox66 »

Hi,
I've a question:
Is passing an array to a procedure in BBC Basic(SDL) the same in BBC Basic(Z80)?
I am writing a program in BBC Basic(Z80) for Agon Light 2 but when I run the program it reports a laconic "Syntax error at line 50"
This is the example code:

Code: Select all

   10 DIM A%(20)
   20 FOR I%=0 TO 20
   30   A%(I%)=RND(50)
   40 NEXT I%
   50 PROC_SHOW(A%())
   60 END
  100 DEF PROC_SHOW(B%())
  110 SIZE%=DIM(B%(),1)
  120 FOR I%=0 TO SIZE%
  130   PRINT B%(I%)
  140 NEXT I%
  150 ENDPROC
It works with SDL but not on Z80.
Any hint?
Thanks,
Paolo
Hated Moron

Re: Passing array to procedure in BBC Basic(Z80)?

Post by Hated Moron »

Neurox66 wrote: Fri 03 Feb 2023, 18:28 Is passing an array to a procedure in BBC Basic(SDL) the same in BBC Basic(Z80)?
No, passing whole arrays to procedures and functions is something that was introduced only in the 32-bit versions of BBC BASIC, so that's ARM BASIC 5 and 6, BBC BASIC for Windows, BBC BASIC for SDL 2.0, the BBC BASIC Console Mode editions and the various varieties of Brandy. 8-bit and 16-bit versions of BBC BASIC don't have that capability; in those, arrays are always global.

We are spoilt by all the BASIC 5 (and later) extensions, and working with 6502 or Z80 BBC BASIC can sometimes feel a bit primitive!
Neurox66
Posts: 2
Joined: Fri 03 Feb 2023, 17:59

Re: Passing array to procedure in BBC Basic(Z80)?

Post by Neurox66 »

Yes, you are right.
We have been spoiled :D :D :D
funkheld
Posts: 30
Joined: Sun 12 Feb 2023, 10:16

Re: Passing array to procedure in BBC Basic(Z80)?

Post by funkheld »

use the bbcbasic24 for the agon.
with the bbcbasic24 you can use the entire 512kb from the agon.
The buffer editing is great from bbcbasic24 (agon).

https://oldpatientsea.github.io/agon-bb ... index.html
https://github.com/breakintoprogram/agon-docs/wiki
https://github.com/breakintoprogram/ago ... mmands-API
You do not have the required permissions to view the files attached to this post.
funkheld
Posts: 30
Joined: Sun 12 Feb 2023, 10:16

Re: Passing array to procedure in BBC Basic(Z80)?

Post by funkheld »

hello everyone, good day.
I'm 76 and I play with the "agon console8 emulator".
this forth24 is great for my hobby.

now I want to tinker around with a (screen) mode...
I haven't yet figured out how to set points in a graphic screen without this vdu.

how do you get the addresses to set your own colored points?

thanks.
best wishes
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: Passing array to procedure in BBC Basic(Z80)?

Post by Richard Russell »

funkheld wrote: Sat 13 Jul 2024, 07:01 this forth24 is great for my hobby...
This appears to have nothing to do with Passing arrays to procedures, nor with BBC BASIC (Forth24 is a version of the Forth language).
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: Passing array to procedure in BBC Basic(Z80)?

Post by Richard Russell »

Hated Moron wrote: Sat 04 Feb 2023, 17:03 We are spoilt by all the BASIC 5 (and later) extensions, and working with 6502 or Z80 BBC BASIC can sometimes feel a bit primitive!
BBC BASIC (Z80) version 5 supports passing entire arrays to procedures, and indeed nearly all of the other BASIC 5 extensions.