Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:51 03 Aug 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 : CMM2 - few questions

Author Message
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 08:13am 19 Oct 2020
Copy link to clipboard 
Print this post

Hi all,
after weekend's first playing with my new CMM2, I found few "problems" I didn't find the solution for. Maybe I just looked not well and the way exists, can somebody help me?

1. DefineFont - can be font defined "on the fly" in running program? I found 2 ways to (re)define font, either load font definition from file or to include DefineFont constants hard into app. But I know the font shape first when app runs...

2. CSUB. Because of complexity to compile assembler prg and prepare it for CSUB, I would like to find some "shorter" way. For example few lines of assembler code to let compile in some web Thumb assembler and put direct into CSUB constant. Can be format of the CSUB be more commented? Can I somehow disassemble working CSUB? I was not successful... Or can be somehow called ARM code direct from BASIC (SYS address)?

3. If I have variable defined for example integer (DIM INTEGER vvv), this variable is also accessible as vvv%, it should be such way?

Thanks for help
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
TweakerRay

Senior Member

Joined: 01/08/2020
Location: Germany
Posts: 138
Posted: 08:29am 19 Oct 2020
Copy link to clipboard 
Print this post

To 1:
you can define Font in a running programm if they have a higher number than 7  I think.
The first 1-7 are the predefined fonts...
So you can for instance define one font at #8 and another font at #9. you can either include the code of defining in the programm or you include the font as a .inc
I think you can do up to #16 font I think...

to 2 and 3 I can not say much.
http://tweakerray.bandcamp.com
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 08:55am 19 Oct 2020
Copy link to clipboard 
Print this post

If you load a font from a file, it has to be #8

You can reload a different #8 as often as you like.

If you included fonts in your program, they can be font number 1 to 16 with the following limitation:
It can be the same as an existing font (except fonts 1, 6 and 7) and in that case it will replace that font.


Jim
VK7JH
MMedit
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 09:02am 19 Oct 2020
Copy link to clipboard 
Print this post

To point 1:
I know the character shape first when app runs, so I need somehow define font "on the fly", so that's not possible, right?

Or could be in DefineFont used variables?
Edited 2020-10-19 19:10 by jirsoft
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 09:17am 19 Oct 2020
Copy link to clipboard 
Print this post

  jirsoft said  CSUB. Because of complexity to compile assembler prg and prepare it for CSUB, I would like to find some "shorter" way.

Sorry, but that is the way it is - there are no shortcuts.
Writing in C and creating CSUBs is complicated.
That is partially why MMBasic is so popular.

  jirsoft said  If I have variable defined for example integer (DIM INTEGER vvv), this variable is also accessible as vvv%, it should be such way?

What is the problem with this?
If DIM INTEGER vvv creates an integer then vvv% refers to the same integer.
Defining vvv as an integer twice is not an error,

Geoff
Geoff Graham - http://geoffg.net
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 09:28am 19 Oct 2020
Copy link to clipboard 
Print this post

Thanks Geoff,
with CSUB I agree, I would like just make some short snippet of code faster...

And I have no problem with INTEGER vvv vs. vvv%, it was just a question, if that's not bug. So the shortest way (smallest amount of written code), wil be:

DIM vvv%

vvv = 2 * vvv

?
Edited 2020-10-19 19:28 by jirsoft
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 10:26am 19 Oct 2020
Copy link to clipboard 
Print this post

  Quote  So the shortest way (smallest amount of written code), wil be:

DIM vvv%

vvv = 2 * vvv

?


Be careful this will only work if OPTION DEFAULT INTEGER is set otherwise you will get an error.

Likewise

OPTION DEFAULT INTEGER
DIM vvv!
vvv = 2 * vvv

will give an error

as will anything after OPTION DEFAULT NONE

much better to stick to either using postscripts or not throughout

  Quote  I know the character shape first when app runs, so I need somehow define font "on the fly", so that's not possible, right?


Create the "on-the-fly" font on an unused page and use BLIT for this requirement
Edited 2020-10-19 20:28 by matherp
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 11:47am 19 Oct 2020
Copy link to clipboard 
Print this post

HI Peter,
I'm still looking for the optimal way, how to declare variables (with OPTION DEFAULT NONE, as that find I as safest), but I think I will stick with prefix (DIM INTEGER...)

With BLIT super simple idea, why I missed it...
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2170
Posted: 01:42pm 19 Oct 2020
Copy link to clipboard 
Print this post

  jirsoft said  


Note that the variable name is "unique" - any variable, regardless of type, can only use the name once.

for instance; you couldn't have V% and V$ in the same program where they can "see" each other... e.g both in the main thread or both in the same SUB or FUNCTION

It might seem obvious that you can't have

Dim Integer V
Dim String V

Neither variable is qualified by its type indicator... and yet it seems harder for some to understand why you can't have

Dim V%
Dim V$

the type indicator does not form part of the variable name, so this would be logically the same as the first example above.

Some Dialects of Basic do allow the variable names to be duplicated across scope, so implicitly the type declaration seems to form some part of the name. An example here; Locomotive Basic will happily allow stuff like

DefInt a-z
v=10' implicitly an integer due to the "defint" above
v$="fred"

But not MMBasic. Small point

If the variables cannot "see" each other then it will work, so...

Dim Integer V

Sub MySub
 Local Float V
End Sub

is fine. Local variable (and statics) inhabit their own little world. The same rules apply *within* that world, but not between worlds.

One caveat, if you have a global variable called V, you can play with that inside a SUB/FUNCTION, but if you declare a Local variable (inside a SUB/FUNCTION) called V, MMBasic will drop the association with the global. If you then try to use it, it will throw an error, see:

dim integer v

sub mysub
local v$'  <--- at this point, I lose contact with the global v (same names)
v=v+2   '<--- this tries to do an implict DIM, which fails
Print v
end sub

> RUN
> mysub
[5] v=v+2
Error: V already declared
>


Simple enough when you get it    Best practice is just to keep variable names unique yourself.
Edited 2020-10-20 00:41 by CaptainBoing
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025