Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:03 04 Jul 2025 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 6 of 16    
Author Message
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2527
Posted: 09:33pm 04 Aug 2022
Copy link to clipboard 
Print this post

Picaxe is ok for robots but not much good for glcd. It's not a compiler. It doesn't make an assembler hex file and flash it. It's basic and works up to a certain speed and easier than asm but not as fast as compiled basic. You can't use an arduino board of course as it's picaxe chips only. gcb uses arduino bootloader so just a usb lead not a rs232 to 3.5 jack to gnd,clk.data or dedicated usb lead,more money, which I found using pickit was pins 27,28 but picaxe used pins 1,2.
I don't know why picaxe has such a dedicated fan club when there's open source basic compilers available. A rp2040 is cheaper.
There is no free basic for rpi pico other than mmbasic that I know of. I got free basic on rpi 400.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7826
Posted: 07:13am 05 Aug 2022
Copy link to clipboard 
Print this post

I think they should have called it a pre-processor really, but I can understand that in an educational context that might be a little confusing. "Compiler" might be easier to un-learn at a later stage. :)

My "miracle" device is the Micromite. MMBasic on a 28-pin PIC is not far short of a miracle in my eyes. I don't know how Geoff managed to do that bit of magic, but I'm really grateful that he did. :) It still makes me smile when I hook one up to Tera Term and have a play.
Mick

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

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2527
Posted: 03:04pm 05 Aug 2022
Copy link to clipboard 
Print this post

@Mixtel90 My "miracle" device is the Micromite. MMBasic on a 28-pin PIC is not far short of a miracle in my eyes. I don't know how Geoff managed to do that bit of magic, but I'm really grateful that he did. :) It still makes me smile when I hook one up to Tera Term and have a play.
Please say more , what pic?
You can get 32bit arduino boards. Are any supported?
I'm happy with rpi pico and mmbasic. I really like all the glcd buttons and dials and gauges and touch interrupts. Better, IMHO than a Nextion touch lcd and a pic/arduino to run it. Cheaper to.
Win 10 sees rpi as pico in devices, not com x. Teraterm finds the rpi pico on win 10 as
com13:usb serial device. putty needs input com port but win 10 doesn't show it as a com number.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7826
Posted: 03:28pm 05 Aug 2022
Copy link to clipboard 
Print this post

https://geoffg.net/micromite.html

GCBasic only supports the UNO as far as I know.
Mick

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

Joined: 18/11/2011
Location: United Kingdom
Posts: 4033
Posted: 04:34pm 05 Aug 2022
Copy link to clipboard 
Print this post

  stanleyella said  Win 10 sees rpi as pico in devices, not com x. Teraterm finds the rpi pico on win 10 as
com13:usb serial device. putty needs input com port but win 10 doesn't show it as a com number.

Bear in mind the pico can be in one of a few modes.

When expecting you to copy across new firmware it appears as a device.

When running firmware it appears as whatever that firmware decides e.g. a USB COM port.

(Also & sadly, Windows can be confused...)

John
Edited 2022-08-06 02:35 by JohnS
 
stanleyella

Guru

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

I tried running some code written in mmedit and click the running man and it saves and gives error messages which I've got to read data to array... it says - error array dimensions. I don't have a clue what's wrong.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3348
Posted: 08:07pm 05 Aug 2022
Copy link to clipboard 
Print this post

cannon is not dimmed.

If you provide code with an error, please provide the line number of the error.
Edited 2022-08-06 06:09 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1128
Posted: 08:31pm 05 Aug 2022
Copy link to clipboard 
Print this post

And why do you have the command DATA after the READ command? Not needed.
Visit Vegipete's *Mite Library for cool programs.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2527
Posted: 08:50pm 05 Aug 2022
Copy link to clipboard 
Print this post

> RUN
[8] Read data,sp1(ptr)
Error : Array dimensions
>

OPTION BASE 0        ' 0 based arrays
OPTION DEFAULT NONE  ' Don't assume a type for variables
'OPTION EXPLICIT
OPTION DEFAULT INTEGER
dim sp1 integer (255)

for ptr=0 to 255
 read data,sp1(ptr)
next ptr
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,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,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
not a clu and amazed mmeditworked, well seems to.. running man button to save and run.
 
lizby
Guru

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

sp1 is not an array. You've defined an array named "integer".
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10197
Posted: 09:04pm 05 Aug 2022
Copy link to clipboard 
Print this post

  Quote  dim sp1 integer (255)


Read the manual for DIM. This is meaningless.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2527
Posted: 09:38pm 05 Aug 2022
Copy link to clipboard 
Print this post

please someone show how to dim array(255) and read data 0 to 255 to the array.
This code gives error
> RUN
[18] Read data,sp1(ptr)
Error : No DATA to read
>
OPTION BASE 0        ' 0 based arrays
'OPTION DEFAULT NONE  ' Don't assume a type for variables
'OPTION EXPLICIT
OPTION DEFAULT INTEGER
dim sp1(255)
CONST bk = RGB(BLack)
const wh = rgb(white)
const bl = rgb(blue)
const gr = rgb(green)
const cy = rgb(cyan)
const re = rgb(red)
const ma = rgb(magenta)
const ye = rgb(yellow)
const br = rgb(brown)

restore
for ptr=0 to 255
 read data,sp1(ptr)
next ptr
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,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,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
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6268
Posted: 09:56pm 05 Aug 2022
Copy link to clipboard 
Print this post

for ptr=0 to 255
read sp1(ptr)
next ptr

you were reading two values on each pass, one into a variable called data and the second into the array.
VK7JH
MMedit
 
stanleyella

Guru

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

line 18 is read data,sp1(ptr)
I don't see my errors. it's annoying, hope it's not mmedit which I've not set up just clicked the running man to save and run.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2527
Posted: 10:13pm 05 Aug 2022
Copy link to clipboard 
Print this post

for ptr=0 to 255
read data,sp1(ptr)
next ptr
The manual says
Reads values from DATA statements and assigns these values to the named
variables. Variable types in a READ statement must match the data types in
DATA statements as they are read.
Arrays can be used as variables (specified with empty brackets, e.g. a()) and
in that case the size of the array is used to determine how many elements are
to be read.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4033
Posted: 10:24pm 05 Aug 2022
Copy link to clipboard 
Print this post

It's not

READ DATA,...

but just

READ ...

John
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6268
Posted: 11:20pm 05 Aug 2022
Copy link to clipboard 
Print this post

If oyu insist on using MMEdit, use the help.
click in the READ word and "F1" for a short one line hint
Hold Shift while pressing F1 key and the full help for the READ command pops up.
The demo in that help should help.

PS,
If Teraterm finds your pico on com13, I would believe it.

Playing with the syntax is much easier using Teraterm and the pico.
You are welcome to continue using my test micromite but the pico is where you need to ed up.

Jim
VK7JH
MMedit
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1128
Posted: 03:38am 06 Aug 2022
Copy link to clipboard 
Print this post

Here's a working version:
OPTION BASE 0        ' 0 based arrays
'OPTION DEFAULT NONE  ' Don't assume a type for variables
'OPTION EXPLICIT
OPTION DEFAULT INTEGER
dim sp1(255)
CONST bk = RGB(BLack)
const wh = rgb(white)
const bl = rgb(blue)
const gr = rgb(green)
const cy = rgb(cyan)
const re = rgb(red)
const ma = rgb(magenta)
const ye = rgb(yellow)
const br = rgb(brown)

restore
for ptr=0 to 255
  read sp1(ptr)
next ptr
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,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,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

cls

for x = 10 to 200
  DrawSprite sp1(),x,25
  line x-1,25,x-1,25+16,1,0   ' erase old image
next x

end

sub DrawSprite arr(),x,y
  local i,j
  for j = 0 to 15
    for i = 0 to 15
      pixel x+i,y+j,arr(j*16+i)
    next i
  next j
end sub

The biggest issue is erasing the previous image. The above just draws a black line on the left edge of the new image, which will erase that portion that didn't get replaced by the new image. Obviously this method is useless for general sprite movement. Better might be to draw a black box at the old location, then draw the sprite at the new location.
Visit Vegipete's *Mite Library for cool programs.
 
stanleyella

Guru

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

Thanks for the replies. I've not used read data since the 80's and it was different to mmbasic. It's use I misinterpreted with mmbasic.
MMedit seems ok, it's more like what I'm used to ie win editor and save to mmbasicprogs in win, then press a button to save/run it to rpipico.
@vegipete- I'll try my method of draw sprite,calculate new position then erase sprite by plotting background the plotting sprite in new position.
Should be flicker free. I'll report back if it works. Cheers.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7826
Posted: 03:36pm 06 Aug 2022
Copy link to clipboard 
Print this post

Don't attempt to mix BASICs. Read the (excellent) manual for MMBasic - it's based on GWBASIC but it's not the same.

On Geoff's site, in the Micromite section, he also has another little book: "Getting Started With The Micromite". Although not directly applicable to the PicoMite it's a good intro to MMBasic. Just bear in mind that there are some quite big differences because of the hardware and, in your case, the PicoMite manual takes precedence.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
     Page 6 of 16    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025