Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 20:07 02 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 5 of 16    
Author Message
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3348
Posted: 11:00am 04 Aug 2022
Copy link to clipboard 
Print this post

  thwill said  I am a religious user of type suffixes on identifiers.


Do you mean "!", "$", "%"? That's better than my non-religious use of a prefix to identify type: iCount for integer, sName for string.

Any other adherents to this religion? For larger programs it might well save some head-scratching.

I think I'll join up.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4300
Posted: 11:43am 04 Aug 2022
Copy link to clipboard 
Print this post

  lizby said  Do you mean "!", "$", "%"?


Exactly.

My earliest MMBasic efforts used OPTION DEFAULT INTEGER so I didn't use % but I it made me uneasy and I have now found the true way to enlightenment and use OPTION DEFAULT NONE and suffixes on all variables (and constants).

Best wishes,

Tom
Edited 2022-08-04 21:43 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7820
Posted: 12:26pm 04 Aug 2022
Copy link to clipboard 
Print this post

I'm a pretty lousy typist so I like to keep it to a minimum. :)

I have a sort of standard which I don't always keep to:

OPTION DEFAULT INTEGER
OPTION EXPLICIT

DIM i,j,x,y,a,b,c,d
DIM t$,k$

i and j are used for loop counters and rarely anything else.
a,b,c,d are multi-purpose globals. a is usually the ASC or INSTR of a k$
x,y are usually co-ordinates, but can be used for other stuff

t$ is almost always a test string. There may be several: t1$, t2$ etc.
k$ is always an inputted string or character.

Additionally I always use LOCAL in functions and subs wherever possible, although I usually treat arrays as globals.

I usually only specify floats if I need them for something. They usually end up with "proper" names like "volts", having been set up with DIM FLOAT volts.
Mick

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

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

I use single-character variable names for what are essentially scratch variables.

My integer standards are Fortran-derived: DIM integer i,j,k,l,m,n. Maybe x,y. Maybe DIM integer p(10) for pins.

For strings, DIM string a,b,c,d,e,s. "s" and "a" are the most likely string scratch variables.

For floats, DIM float f.

Otherwise, typed by "!", "$", "%" might do the trick (if I could just remember which was which for "!" and "%". ("!" is not like "I" for integer; "%" is not containing a decimal point as in 3.5%. It's the "nots" that will confuse me. I guess with practice ...
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
stanleyella

Guru

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

I seem to have caused problems with asking about constants. If I am trying a new basic then I will use knowledge of previous basics to start like I used what I learnt in the 80's with picaxe basic, which was called a compiler but wasn't.
I tried converting picaxe basic to great cow basic but ended up starting from scratch as there's too many differences.
It's the same with mmbasic on rp2040. The idea that memory, especially ram is plentiful takes a while to appreciate and trying to make my code as efficient as possible seems not needed as much. Thanks @Lizby for empathy.
I used mmbasic constants as there is no define like #define gpio 5=left which would be const gpio 5=left.
in the program I'd use if left=1 then...have to try it not ask if it's correct.
I'm using
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)
which in mmedit is all upper case but copying to here and it's become lower case.
I will use OPTION DEFAULT INTEGER as first line then I can use pixel x,y,wh or
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
then read it to an array
dim sprite1(255)
for ptr=0 to 255
 read data,sprite1(ptr)
next ptr

then to draw it
sub sprite
 ptr=0
 for spht=0 to 15
   for spw=0 to 15
     pixel spx(temp)+spw,spy(temp)+spht,sprite(ptr)
     ptr=ptr+1
   next spw
 next spht
end sub
I'm not used to using a terminal like teraterm as win 10 and putty doesn't see rpi pico com port, teraterm it's usb com port.
 
lizby
Guru

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

"dim sprite(225)" will make sprite a floating point array (which may work anyway) (unless preceded by "OPTION DEFAULT INTEGER").

To make sprite an integer, "dim integer sprite(225)".

Note that it reduces typing if you say, for instance "DIM INTEGER i,j,k" as opposed to "DIM i as integer, j as integer, k as integer".

No one with knowledge of the beast ever said that PICAXE Basic was compiled. Your code is "tokenized" before being downloaded to the PICAXE chip, and the PICAXE firmware on the chip executes the tokenized code.

~
Edited 2022-08-05 01:13 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1220
Posted: 03:36pm 04 Aug 2022
Copy link to clipboard 
Print this post


dim sprite1(255)
for ptr=0 to 255
read data,sprite1(ptr)
.......
then to draw it
sub sprite
ptr=0
for spht=0 to 15
  for spw=0 to 15
    pixel spx(temp)+spw,spy(temp)+spht,sprite(ptr)
    ptr=ptr+1
  next spw
next spht
end sub


is dangeros or would not run in the new Versions of PicoMite VGA
The "Blit" command is replaced by "Sprite", Sprite is a Keyword

just my 2 cents
Edited 2022-08-05 01:38 by Martin H.
'no comment
 
stanleyella

Guru

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

Sorry @lizby sir. picaxe is sold as a compiler but even in line assembler is interpreted.
It was interesting but fell down with no glcd support like I wrote ssd1306 and plot and line for ili9341 for picaxe but slowwww.
Great cow basic I sent ssd1306 and ili9341 boards to their forum guru and he, Anobium, wrote drivers for me.. and everyone else. I then asked for xor pixel on ssd1306 and read pixel on ili9341 which he implemented. Here's a video of me testing read pixel to show it was worth anobiums effort. https://www.youtube.com/watch?v=SGJFApFqx1Q
mmbasic has glcd well implemented... which is why I'm using it :)
I tried my own "ili9341 blitter" to read the background but put it on the back boiler cos playing with mmbasic taking up my free time.
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1127
Posted: 04:25pm 04 Aug 2022
Copy link to clipboard 
Print this post

How many sprites do you plan to use? And refresh my memory, exactly what hardware are you running this on? Is an SD card connected?

Personally, I prefer to store the image data as described by Martin H about half way down page 2 of this thread. (The uncompressed version, which if you squint, you can kinda almost see the image in the sprite data.)

Drawing the sprites pixel by pixel strikes me as being far too slow, but I haven't tried it so what do I know. BLIT READ, BLIT LOAD and BLIT WRITE could become your friends.
Visit Vegipete's *Mite Library for cool programs.
 
lizby
Guru

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

  stanleyella said  Sorry @lizby sir. picaxe is sold as a compiler


I'd like to see a link where Rev-Ed (the maker of Picaxe) says that it's a compiler. I don't think you will be able to provide it (user of Picaxe since 2008).
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
stanleyella

Guru

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

@vegipete - I plan on 8 "aliens", a cannon, 3 missiles, each alien can drop a bomb..
sort of galaxian/space invaders. I have it running in gcbasic on arduino/pic ili9341
https://www.youtube.com/watch?v=9pys3Y8_bns&t=5s
Converting to mmbasic but it's all new like memory slots and needing terminal not an ide. Oh well, I'm making progress and appreciate the help.
 
stanleyella

Guru

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

@lizby I do remember picaxe saying it was a compiler but can't find any reference now.
I posted on the picaxe forum it was a con. Maybe they removed all reference to compiled basic and replaced with tokenized?? I erased my 28x2's ie 18f25k22 and used gcb.
 
lizby
Guru

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

  stanleyella said  @lizby I do remember picaxe saying it was a compiler but can't find any reference now.

You can't find the reference of Rev-Ed saying it was compiled because it doesn't say that and hasn't said that. It's been tokenized since the beginning (at least in my experience of picaxe since 2008).
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Mixtel90

Guru

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

Is this it?  https://picaxe.com/software/drivers/picaxe-compilers/

I'm not sure if it's the program that produces the axe file or something else.
Mick

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

Guru

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

@vegipete I'm using rp2040 aka rpi pico with mmbasic v4 NOT the beta vga with ili9341 which does lcdtest and draw circles and lcdtouch which calibrated and is accurate.. top marks, works well, better than gcb.
When I'm familiar with mmbasic I think I'm going to like it's sophisticated graphic abilities, they're not trivial but just what was needed.
I've written dials and it's boring trig. https://www.youtube.com/watch?v=axHTYdH9WW8
 
stanleyella

Guru

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

@Mixtel90 - yes sir  https://picaxe.com/software/drivers/picaxe-compilers/
I knew I saw it as a compiler but it's not. At my age I think I'm loosing the plot sometimes but remember moaning on the picaxe forum it was a con. Even the in line assembler wont speed things up as it's interpreted.
mega 328 uno/nano with gcb much better and free.
 
lizby
Guru

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

  Mixtel90 said  Is this it?  https://picaxe.com/software/drivers/picaxe-compilers/

Well, I apologize for being absolute about it. Those "compilers" don't produce machine code which the microprocessor executes directly, but tokenized code. The word usage would make a difference to those who have used compilers before, but probably not to most of Rev-Ed's intended users--students who are learning to use basic as part of a course in a school.

To call the programs "tokenizers" might well be more confusing to the uninitiated than to call them "compilers". They run on a PC and massage the code which the user writes into a different and more compressed form, which they download to the microprocessor; Picaxe firmware preloaded on the microprocessor interprets and executes that tokenized code.

But if you have to buy a PICAXE chip, rather than the Microchip part into which the PICAXE firmware has been loaded, you should understand that the "compiler" is not actually producing machine code which can run stand-alone on the bare chip.

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

Guru

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

@vegipete - I thought about plotting the sprite or user defined graphic then blitting it to a buffer then erase it then use the blit commands but early days. This has great graphic potential. I hacked the gcb glcd ili9341 include lib to find there's a send word and the hardware to use it and how to fill a box with height,width,x,y,sprite data(pointer). The ili9341 data sheet is no fun.
 
stanleyella

Guru

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

Checking https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=7249
can't be that hard... it's basic?!? Gonna re-read the post about using mmedit or notepad++ and buttons to copy and paste into teraterm and where to save it if not the text in windows mmedit or notepad++ then run it. This is where I have problems like not a clue.
I got an sd card fitted to the ili9341 and mmbasic reads it.
 
TassyJim

Guru

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

  stanleyella said  I'm not used to using a terminal like teraterm as win 10 and putty doesn't see rpi pico com port, teraterm it's usb com port.

If your PC can't see the com port you will have difficulties. If Teraterm and Putty don't see it, nothing will.

I strongly recommend you get that sorted and start using   a terminal for your initial learning the syntax. It makes short realtime code testing easy.

Jim
VK7JH
MMedit
 
     Page 5 of 16    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025