Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 16:12 18 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : dim var as byte

     Page 1 of 16    
Author Message
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 1639
Posted: 04:53pm 02 Aug 2022
Copy link to clipboard 
Print this post

 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 1639
Posted: 05:01pm 02 Aug 2022
Copy link to clipboard 
Print this post

Dim var as byte gets accepted in mmedit. Does it work or are the minimal var values words?
What is the best way of adding minus values or even declaring them. I don't want floating point so dim all vars.
dx=-2:dy=-4
spx=spx+dx:spy=spy+dy
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3828
Posted: 05:51pm 02 Aug 2022
Copy link to clipboard 
Print this post

Hi there,

MMBasic doesn't have a BYTE type, so don't know what is going on there. The supported types are INTEGER, FLOAT and STRING.

On recent 'mite platforms INTEGER and FLOAT are both 64-bit not sure about historical platforms, I think the CMM1 had 32-bit FLOATs and no INTEGERs.

INC spx, dx
INC spy, -dy


is faster than:
spx = spx + dx
spy = spy - dy


Regarding declaration I suggest beginning every program with the "holy trinity":
OPTION BASE 0        ' 0 based arrays
OPTION DEFAULT NONE  ' Don't assume a type for variables
OPTION EXPLICIT      ' Force variables to be declared in advance with
                     ' DIM, LOCAL, CONST or STATIC


Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3008
Posted: 06:02pm 02 Aug 2022
Copy link to clipboard 
Print this post

"dim var as byte" gives the error "variable type" on both picomite and MMBasic for Windows.

"dim byte var" doesn't give an error on either, but on MMBasic for Window, both byte and var are variables. On PicoMite, "var=1" gives "Error: Unknown Command".

With "dim byte,var" on the Picomite, "var=1" works.

I'm not sure why "DIM byte var" (with no comma) doesn't give a syntax error on both.

~
Edited 2022-08-03 04:08 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 1639
Posted: 06:27pm 02 Aug 2022
Copy link to clipboard 
Print this post

Thanks. MMbasic is new. I'm converting a great cow basic program to mmbasic on rpi pico. Lots of differences. Would read data+256 work?
I'm using arrays cos I haven't figured data and read but is this how to set up an array with values.. colours..word values.
For minus numbers do I use integers or is -1=65535?
I have not run/tested as I'm using mmedit v4.xxx and not a clue how to make it run with pico connected. Using teraterm but not happy using a terminal, It's all strange.

option explicit
OPTION DEFAULT NONE

dim sprite_x(8),sprite_y(8),sprite_lastx(8),sprite_lasty(8),sprite_dirx(8),sprite_diry(8) as word



'dir right_button in
'dir fire_button in
dim hiscore,hits as word
hiscore=0
'white, black,blue, green, cyan, red, magenta, yellow, brown, white, orange, pink, gold, salmon, beige, lightgrey and grey (orUSA spelling gray/lightgray).
CONST BLACK=bk
const white=wh
const blue=bl
const green=gr
const cyan=cy
const red=re
const magenta=ma
const yellow=ye
const brown=br

Start:

Randomize

dim sprite1(256) as word
dim sprite2(256) as word
dim cannon(120) as word
dim missile (16) as word

sprite1=(wh,bl,bl,bl,bl,bk,bk,bk,bk,bk,bk,bl,bl,bl,bl,wh
bk,bl,re,re,re,bl,bl,bk,bk,bl,bl,re,re,re,bl,bk
bk,bk,bl,re,re,re,bl,bk,bk,bl,re,re,re,bl,bk,bk
bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk
bk,bk,bk,bk,bl,wh,bl,bk,bk,bl,wh,bl,bk,bk,bk,bk
bk,bk,bk,bk,bk,bl,bl,bk,bk,bl,bl,bk,bk,bk,bk,bk
bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk
bk,bk,bk,bk,ye,ye,ye,bk,bk,ye,ye,ye,bk,bk,bk,bk
bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk
bk,ye,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,ye,bk
bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk
ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bl,ye
ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye
ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye
bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk
bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk)

sprite2=(bl,bl,bl,bl,bl,bk,bk,bk,bk,bk,bk,bl,bl,bl,bl,bl
bk,bl,re,re,re,bl,bl,bk,bk,bl,bl,re,re,re,bl,bk
bk,bk,bl,wh,wh,re,bl,bk,bk,bl,re,wh,wh,bl,bk,bk
bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk
bk,bk,bk,bk,bl,wh,bl,bk,bk,bl,wh,bl,bk,bk,bk,bk
bk,bk,bk,bk,bk,bl,bl,bk,bk,bl,bl,bk,bk,bk,bk,bk
bk,bk,bk,bk,bk,bk,bk,ye,ye,bk,bk,bk,bk,bk,bk,bk
bk,bk,bk,bk,bk,ye,ye,bk,bk,ye,ye,bk,bk,bk,bk,bk
bk,bk,bk,bk,ye,ye,bk,bk,bk,bk,ye,ye,bk,bk,bk,bk
bk,bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk,bk
bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk
bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk
bk,bk,bk,ye,ye,bk,bk,bk,bk,bk,bk,ye,ye,bk,bk,bk
bk,bk,bk,bk,ye,ye,bk,bk,bk,bk,ye,ye,bk,bk,bk,bk
bk,bk,bk,bk,bk,ye,bk,bk,bk,bk,ye,bk,bk,bk,bk,bk
bk,bk,bk,bk,bk,bk,ye,bk,bk,ye,bk,bk,bk,bk,bk,bk)

cannon=(bk,bk,bk,bk,bk,wh,wh,bk,bk,bk,bk,bk
bk,bk,bk,bk,ye,cy,cy,ye,bk,bk,bk,bk
bk,bk,bk,ye,cy,wh,wh,cy,ye,bk,bk,bk
bk,bk,bk,ye,cy,cy,cy,cy,ye,bk,bk,bk
bk,bk,ye,ye,cy,wh,wh,cy,ye,ye,bk,bk
bk,bk,ye,cy,cy,cy,cy,cy,cy,ye,bk,bk
bk,ye,bl,bl,bl,re,re,bl,bl,bl,ye,bk
ye,ye,bl,bl,bl,re,re,bl,bl,bl,ye,ye
bk,bk,ye,re,re,re,re,re,re,ye,bk,bk
bk,bk,bk,ye,fu,fu,fu,fu,ye,bk,bk,bk)

missile=(wh,wh
re,re
ye,ye
wh,wh
wh,wh
ye,ye
re,re
wh,wh)
'
do
loop
'
sub sprite1
 ptr=0
 for spht=0 to 15
   for spw=0 to 15
     pset=sprite1(ptr)
     pixel spx(temp)+spw,spy(temp)+spht,pset
     ptr=ptr+1
   next spw
 next spht
end sub
'
sub sprite2
 ptr=0
 for spht=0 to 15
   for spw=0 to 15
     pset=sprite2(ptr)
     pixel spx(temp)+spw,spy(temp)+spht,pset
     ptr=ptr+1
   next spw
 next spht
end sub
'
sub erase_sprite 'fills window background colour
 for spht=0 to 15
   for spw=0 to 15
   (oldspx(temp),oldspy(temp)
     pixel oldspx(temp)+spw,oldspy(temp)+spht,black
     ptr=ptr+1
   next spw
 next spht
end sub
'

end sub
'
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8565
Posted: 06:30pm 02 Aug 2022
Copy link to clipboard 
Print this post

You can't split MMbasic commands across lines

cannon=(bk,bk,bk,bk,bk,wh,wh,bk,bk,bk,bk,bk
bk,bk,bk,bk,ye,cy,cy,ye,bk,bk,bk,bk
bk,bk,bk,ye,cy,wh,wh,cy,ye,bk,bk,bk
bk,bk,bk,ye,cy,cy,cy,cy,ye,bk,bk,bk
bk,bk,ye,ye,cy,wh,wh,cy,ye,ye,bk,bk
bk,bk,ye,cy,cy,cy,cy,cy,cy,ye,bk,bk
bk,ye,bl,bl,bl,re,re,bl,bl,bl,ye,bk
ye,ye,bl,bl,bl,re,re,bl,bl,bl,ye,ye
bk,bk,ye,re,re,re,re,re,re,ye,bk,bk
bk,bk,bk,ye,fu,fu,fu,fu,ye,bk,bk,bk)


You need to use DATA and READ, they really are very easy.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 1639
Posted: 06:54pm 02 Aug 2022
Copy link to clipboard 
Print this post

@matherp If I use data then could read data+256 work? I am converting basic that used tables.
would this be ok for setting an array?... editing missed the commas
cannon=(bk,bk,bk,bk,bk,wh,wh,bk,bk,bk,bk,bk,
bk,bk,bk,bk,ye,cy,cy,ye,bk,bk,bk,bk,
bk,bk,bk,ye,cy,wh,wh,cy,ye,bk,bk,bk,
bk,bk,bk,ye,cy,cy,cy,cy,ye,bk,bk,bk,
bk,bk,ye,ye,cy,wh,wh,cy,ye,ye,bk,bk,
bk,bk,ye,cy,cy,cy,cy,cy,cy,ye,bk,bk,
bk,ye,bl,bl,bl,re,re,bl,bl,bl,ye,bk,
ye,ye,bl,bl,bl,re,re,bl,bl,bl,ye,ye,
bk,bk,ye,re,re,re,re,re,re,ye,bk,bk,
bk,bk,bk,ye,fu,fu,fu,fu,ye,bk,bk,bk)

I can set up data for images but how to select 256 elements ie words if they're colours is not clear.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5699
Posted: 07:31pm 02 Aug 2022
Copy link to clipboard 
Print this post

If you are using DATA and READ then you need to read the data using a loop. You can't simply fill an array in one statement.
e.g.

DIM cannon(120)

RESTORE cannon
for i=1 to 120
READ cannon(i)
next

cannon:  'this is a label
DATA bk,bk,bk,bk,bk,wh,wh,bk,bk,bk,bk,bk
DATA bk,bk,bk,bk,ye,cy,cy,ye,bk,bk,bk,bk
DATA bk,bk,bk,ye,cy,wh,wh,cy,ye,bk,bk,bk
DATA bk,bk,bk,ye,cy,cy,cy,cy,ye,bk,bk,bk
DATA bk,bk,ye,ye,cy,wh,wh,cy,ye,ye,bk,bk
DATA bk,bk,ye,cy,cy,cy,cy,cy,cy,ye,bk,bk
DATA bk,ye,bl,bl,bl,re,re,bl,bl,bl,ye,bk
DATA ye,ye,bl,bl,bl,re,re,bl,bl,bl,ye,ye
DATA bk,bk,ye,re,re,re,re,re,re,ye,bk,bk
DATA bk,bk,bk,ye,fu,fu,fu,fu,ye,bk,bk,bk

Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 1639
Posted: 07:58pm 02 Aug 2022
Copy link to clipboard 
Print this post

how would I read various blocks of data? is there just one data statement?
sorry I'm dim.

data
wh,bl,bl,bl,bl,bk,bk,bk,bk,bk,bk,bl,bl,bl,bl,wh,
bk,bl,re,re,re,bl,bl,bk,bk,bl,bl,re,re,re,bl,bk,
bk,bk,bl,re,re,re,bl,bk,bk,bl,re,re,re,bl,bk,bk,
bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk,
bk,bk,bk,bk,bl,wh,bl,bk,bk,bl,wh,bl,bk,bk,bk,bk,
bk,bk,bk,bk,bk,bl,bl,bk,bk,bl,bl,bk,bk,bk,bk,bk,
bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,
bk,bk,bk,bk,ye,ye,ye,bk,bk,ye,ye,ye,bk,bk,bk,bk,
bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk,
bk,ye,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,ye,bk,
bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,
ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bl,ye,
ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,
ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,
bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,
bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk,

'data+256
bk,bk,bk,bk,bk,wh,wh,bk,bk,bk,bk,bk,
bk,bk,bk,bk,ye,cy,cy,ye,bk,bk,bk,bk,
bk,bk,bk,ye,cy,wh,wh,cy,ye,bk,bk,bk,
bk,bk,bk,ye,cy,cy,cy,cy,ye,bk,bk,bk,
bk,bk,ye,ye,cy,wh,wh,cy,ye,ye,bk,bk,
bk,bk,ye,cy,cy,cy,cy,cy,cy,ye,bk,bk,
bk,ye,bl,bl,bl,re,re,bl,bl,bl,ye,bk,
ye,ye,bl,bl,bl,re,re,bl,bl,bl,ye,ye,
bk,bk,ye,re,re,re,re,re,re,ye,bk,bk,
bk,bk,bk,ye,fu,fu,fu,fu,ye,bk,bk,bk
How do I access blocks of data and use them directly to plot pixels?
Thinking data is program memory but maybe not as fast as reading array in ram.
MMbasic is so new.
Edited 2022-08-03 06:25 by stanleyella
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3649
Posted: 08:30pm 02 Aug 2022
Copy link to clipboard 
Print this post

  stanleyella said  how would I read various blocks of data? is there just one data statement?

Along the lines Mixtel90 showed.

Use a unique label for each block, do a RESTORE label, then use a loop to read in the data.

You need each separate line of data to start with the word DATA.

John
Edited 2022-08-03 06:30 by JohnS
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5699
Posted: 08:30pm 02 Aug 2022
Copy link to clipboard 
Print this post

No, you need to split your data into chunks of up to one screen line long. No data statement can be longer than a single screen line. However, when you are reading the statements READ jumps from the end of the line to the first item in the next DATA statement automatically.

DATA*256 isn't supported at all in MMBasic.

You can put all your data into one block then read the individual arrays (one after another) if you like. I prefer to use RESTORE <label> before each loop. That way I can read the arrays out of sequence if I want to. It also makes it easier to keep track of.

e,g,

DIM a(5), b(3), c(4)

RESTORE first
for i-1 to 5
READ a(i)
next

RESTORE third
for i=1 to 4
read c(i)
next

RESTORE second
for i=1 to 3
READ b(i)
next


first:
DATA 10,20,30,40,50

second:
DATA 100,200,300

third:
DATA 101,102,103,104

Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 1639
Posted: 08:56pm 02 Aug 2022
Copy link to clipboard 
Print this post

@Mixtel90, Thanks. Would this work please? Last time I used read-data was sinclair zx spectrum.
restore sprite1
draw sprite1 data
restore cannon
draw cannon data

sprite1:
data wh,bl,bl,bl,bl,bk,bk,bk,bk,bk,bk,bl,bl,bl,bl,wh
data bk,bl,re,re,re,bl,bl,bk,bk,bl,bl,re,re,re,bl,bk
data bk,bk,bl,re,re,re,bl,bk,bk,bl,re,re,re,bl,bk,bk
data bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk
data bk,bk,bk,bk,bl,wh,bl,bk,bk,bl,wh,bl,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bl,bl,bk,bk,bl,bl,bk,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk
data bk,bk,bk,bk,ye,ye,ye,bk,bk,ye,ye,ye,bk,bk,bk,bk
data bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk
data bk,ye,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,ye,bk
data bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk
data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bl,ye
data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye
data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye
data bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk
data bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk

cannon:
data bk,bk,bk,bk,bk,wh,wh,bk,bk,bk,bk,bk
data bk,bk,bk,bk,ye,cy,cy,ye,bk,bk,bk,bk
data bk,bk,bk,ye,cy,wh,wh,cy,ye,bk,bk,bk
data bk,bk,bk,ye,cy,cy,cy,cy,ye,bk,bk,bk
data bk,bk,ye,ye,cy,wh,wh,cy,ye,ye,bk,bk
data bk,bk,ye,cy,cy,cy,cy,cy,cy,ye,bk,bk
data bk,ye,bl,bl,bl,re,re,bl,bl,bl,ye,bk
data ye,ye,bl,bl,bl,re,re,bl,bl,bl,ye,ye
data bk,bk,ye,re,re,re,re,re,re,ye,bk,bk
data bk,bk,bk,ye,fu,fu,fu,fu,ye,bk,bk,bk

is reading data from program memory slower than reading from an array in ram?
Edited 2022-08-03 07:00 by stanleyella
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5699
Posted: 09:04pm 02 Aug 2022
Copy link to clipboard 
Print this post

Nope, sorry. The DATA statements are only that - lists of data. They are basically REM statements that can be read using the READ command. To use them you have to load an array with them first, hence the for-next loops.

label: is a line label called "label"

RESTORE <label> moves the read pointer to the line with the label on it.

for i=1 to n
READ a(i)
next

is a loop that READs each value in turn and puts it into the array element i.

The DATA statement is the only way that you can read from program memory (that is actually stored as part of the program). It can only be accessed by the READ command - it's not usable directly. What READ does is to read a value from the program area of memory so that it can be stored in the variables area, so once it's transferred you are accessing it as a variable, not as DATA statements.
Edited 2022-08-03 07:09 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 1639
Posted: 09:16pm 02 Aug 2022
Copy link to clipboard 
Print this post

by the way it seems from the manual that an array can be
dim arrayvar(9) as word
arrayvar=(0,1,2,3,4,65535,65534,65533,65532,65531)

arrays start at 0 as 1st element
please correct me if I'm wrong. The manual is not clear as is gwbasic help.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5699
Posted: 09:27pm 02 Aug 2022
Copy link to clipboard 
Print this post

You can do stuff like
DIM INTEGER a(5)=(0,1,2,3,4,5)
Note that the line length will restrict you to how many items you can stuff the array width - and you can't append multiple lines.

You can't do
DIM a(4)
a=(0,1,2,3,4)

as a and a() cause a variables collision. Only the second is an array.


OPTION BASE 1
will make arrays start at 1
OPTION BASE 0
is the default, starting at the zeroeth element.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 1639
Posted: 09:31pm 02 Aug 2022
Copy link to clipboard 
Print this post

@Mixtel90- Thanks again. I use Great Cow Basic which uses tables in prog mem and pics don't have much ram usually and they are usable anytime for sprite data.
I don't see reading sprite data to arrays useful if the array can be directly filled ie
dim cannon(120) as word
cannon=(bk,bk,bk,bk,bk,wh,wh,bk,bk,bk,bk,bk,
bk,bk,bk,bk,ye,cy,cy,ye,bk,bk,bk,bk,
bk,bk,bk,ye,cy,wh,wh,cy,ye,bk,bk,bk,
bk,bk,bk,ye,cy,cy,cy,cy,ye,bk,bk,bk,
bk,bk,ye,ye,cy,wh,wh,cy,ye,ye,bk,bk,
bk,bk,ye,cy,cy,cy,cy,cy,cy,ye,bk,bk,
bk,ye,bl,bl,bl,re,re,bl,bl,bl,ye,bk,
ye,ye,bl,bl,bl,re,re,bl,bl,bl,ye,ye,
bk,bk,ye,re,re,re,re,re,re,ye,bk,bk,
bk,bk,bk,ye,fu,fu,fu,fu,ye,bk,bk,bk)

In mmedit only 8 colour short cuts are recognised, no pink,brown,grey
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5699
Posted: 09:39pm 02 Aug 2022
Copy link to clipboard 
Print this post

The array can only be directly filled in the DIM statement, and only to the maximum length of a single editor line. It simply doesn't work anything like GCBASIC. You can't have tables in program memory.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 1639
Posted: 09:39pm 02 Aug 2022
Copy link to clipboard 
Print this post

It seems the manual is wrong

You can't do
DIM a(4)
a=(0,1,2,3,4)
from the manual
Arrays can also be initialised when they are declared by adding an equals
symbol (=) followed by a bracketed list of values at the end of the
declaration. For example:
DIM INTEGER nbr(4) = (22, 44, 55, 66, 88)
or DIM s$(3) = ("foo", "boo", "doo", "zoo")
Note that the number of initialising values must match the number of
elements in the array including the base value set by OPTION BASE. If a
multi dimensioned array is initialised then the first dimension will be
initialised first followed by the second, etc.
Also note that the initialising values must be after the LENGTH qualifier (if
used) and after the type declaration (if used)
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5699
Posted: 09:49pm 02 Aug 2022
Copy link to clipboard 
Print this post

The PicoMite has 16 colours (including black and white). You can easily set up whatever colour names you want:
CONST pink=RGB(255,150,150) 'or something like that - I've not checked
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 1639
Posted: 09:54pm 02 Aug 2022
Copy link to clipboard 
Print this post

So would this work? It would be ok as rpi pico has lots of ram.
dim word cannon(120)=(bk,bk,bk,bk,bk,wh,wh,bk,bk,bk,bk,bk,
bk,bk,bk,bk,ye,cy,cy,ye,bk,bk,bk,bk,
bk,bk,bk,ye,cy,wh,wh,cy,ye,bk,bk,bk,
bk,bk,bk,ye,cy,cy,cy,cy,ye,bk,bk,bk,
bk,bk,ye,ye,cy,wh,wh,cy,ye,ye,bk,bk,
bk,bk,ye,cy,cy,cy,cy,cy,cy,ye,bk,bk,
bk,ye,bl,bl,bl,re,re,bl,bl,bl,ye,bk,
ye,ye,bl,bl,bl,re,re,bl,bl,bl,ye,ye,
bk,bk,ye,re,re,re,re,re,re,ye,bk,bk,
bk,bk,bk,ye,fu,fu,fu,fu,ye,bk,bk,bk)

all help appreciated... not much on line ie examples
 
     Page 1 of 16    
Print this page
© JAQ Software 2024