Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:02 11 Nov 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 : CMM Library Load

Author Message
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1106
Posted: 11:43am 25 Mar 2018
Copy link to clipboard 
Print this post

Hi,
I'm trying to work out how to use Libraries on a CMM (4.5) & not having much success.
I made a simple lib program "Hello.lib" which I can load to & remove from the CMM via the MMChat window ok having put it on the SD card.

"Hello.lib"
Hello:
print "Hello"
Return

After doing a LIBRARY LOAD "hello.lib", when I type Gosub Hello, I get a reply "Label not found" message. Loading the library from with a program gives the same results.
If I type 'Run "Hello.lib" ' it prints Hello ok but with the 'Nothing to return to error' which is to be expected.

Any help appreciated. (I have read the blurb in the manual but I find it a bit hard to understand in places)

BTW, I am having much fun with my CMM (Altronics kit). Be interesting to see what Geoff comes up with in the updated version. My wishes are for far more memory which I assume it will have and easier external access to all the I/O pins. I am not a gamer. I did have to bypass the series diode after the 5V regulator to give a full 5V (was ~4.7V) so an oldish RF TRX module would work properly. The diode from the USB socket 5V was also cut to prevent voltage feedback from the USB to the regulator.

ChopperP
ChopperP
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3308
Posted: 01:32pm 25 Mar 2018
Copy link to clipboard 
Print this post

The Maximite is having a bit of a resurgence - probably due to the 8-bit guy's review.

I think that the problem that you are having is because you are not using a proper user defined subroutine. You can only have defined functions and subroutines in the library, anything else will be ignored. Defined functions and subroutines are explained on page 18 of the manual.

Try loading this with LIBRARY LOAD:
Sub Hello
print "Hello"
End Sub

You can test it with this simple program:
Print "Testing library"
Hello
End

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

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1106
Posted: 12:04am 26 Mar 2018
Copy link to clipboard 
Print this post

Thanks Geoff, that worked.

Still not clear on why we have "Gosub Sub, Sub Label: & Return" and
"Mysub, Sub Mysub & End Sub". Obliviously with the latter, you can pass values etc, but I like seeing a Gosub rather than just a statement in my programs.

BTW, I got my CMM years ago when the kit was first released buy Altronics. Only stops on "Not Enough Memory!!!". The library Load was my latest endeavour to free up more memory. More to do.

ChopperP
ChopperP
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9750
Posted: 12:19am 26 Mar 2018
Copy link to clipboard 
Print this post

I was a BIG user of GOSUB myself for a long time, but the more advanced SUB/END SUB allow you to do things you can't do with a standard GOSUB.

GOSUB is actually not the preferred method these days, with SUB/END SUB being more standard for most programs. GOSUB is still supported, just so that those who prefer to use that, still can.

It is a matter of choice to some extent, and there is no really WRONG way to do it. If GOSUB does what you want, then fine.

I quite like just being able to have a single line statement in the code to call a SUB though, such as GET_SETTINGS or SEND_PAGE. That looks neater TO ME now then GOSUB GET_SETTINGS or GOSUB SEND_PAGE. That's just me and my 2c though.

I also never used to use DO/LOOP either. Most of my programs were written using labels and GOTO's all over the place, but I have taught myself(with help from members here) to standardize more on having one master DO/LOOP, and EVERYTHING the program does, is inside that one master loop - including more DO/LOOP's, IF/THEN's etc - everything. There is no law saying you HAVE to do it that way - that's why GOTO is still supported, but generally it is encouraged that you NOT use GOTO any more then you have to, and let loops do all your work for you. It does make sense once you get into doing that way, but I have to admit, I was unwilling to leave my labels and handfuls of GOTO's behind, but it did make debugging code hellish when the code can jump anywhere on the whim of a GOTO command! Much easier to debug with loops then jumping-spider GOTO's.

Tra-la-la.....I think I may have digressed a little....
Smoke makes things work. When the smoke gets out, it stops!
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1106
Posted: 01:17am 26 Mar 2018
Copy link to clipboard 
Print this post

Hi Grogster,

I've been following your progress on TBS since the Maximite came on the scene & I have been totally amazed at what you have accomplished in that time. Yes many of your 5500+ posts were asking questions that others including myself were not game to ask.(Heck, I've only just recently plucked up the courage to join up). Thanks for all your input.

I see what you are getting at with single line statements. May have a rethink. I do use them on a uMite program where I have to pass values.
My 890 line CMM prog only has 1 GOTO in it which I have not worked out how to get around it. Minor issue. Loops, IF/THEN's used etc, but still a dogs breakfast :-). Slowly tidying it up. Next step is to find out what else can be transferred to library files.

It's fine to digress.

Thanks again for the reply

ChopperP

ChopperP
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9750
Posted: 02:29am 26 Mar 2018
Copy link to clipboard 
Print this post

Kind words, thank you.

Never be afraid to ask. This forum is quite probably the friendliest one on the net. Some forums are not, and newbie questions can get somewhat shot-down by a smart-arse member as being not worth their time/go read the manual etc. I am sure we have all just about come across forums like that.

But here new questions have always been welcomed I have found, and the forum is very actively policed by admin(Gizmo/Glenn) so any threads that get out of bounds are stopped.

When I first joined, it was right after Silicon Chip published the Black-and-White Maximite. I was a big user of PICAXE chips at the time, but some of the things I wanted to do were limited by a 8-bit core. PICAXE is still great for simple stuff though, and I still use them where a MM chip is overkill. The first problem I had with MMBASIC was learning how to work with serial. I seem to recall that the original B/W Maximite did not have serial ports at all - not even bit-banged software ones.

I was always a fan of BASIC, even though many other programmers scoffed at it. I taught myself programming on an Atari 800XL back in the 80's when I was a teenager. At a whole 1.6MHz core speed, with the BASIC interpreter on top of that, Atari BASIC was quite slow, but it suited the purposes for a 'Home Computer' of the time.

A powerful BASIC will do more to encourage people into programming then C ever could hope to do, IMHO. Let me be clear about that - C is superior to BASIC. No doubt about that. But it is a pain in the arse to learn if you have never programmed before. That's why I gave up on Arduino - too hard to learn when time is money.

People like Geoff and Peter(matherp) AMAZE me that they can cook up C stuff so easily. Naturally, they will have had years of experience, but when I look at C source-code, it is gobble-de-gook to me - it makes NO sense. But then, I freely admit to not knowing how to even blink an LED in C, so I guess I would say that.




Smoke makes things work. When the smoke gets out, it stops!
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1106
Posted: 07:34am 26 Mar 2018
Copy link to clipboard 
Print this post

I've just decommissioned a PICAXE board I wss using. Got another one I've got to fix up or do something else with. Done a fair bit with them. Maths the limiting factor for me.
My BASIC started with a VIC-20. Had fun with that. Also dabbled with a bit of VBDOS. Attempted "C" about 3 times, the final lot when I was at Uni. Managed to print "Hello World" but not much more without a lot of help. MMBasic is getting quite complicated as we find more & more stuff to do with the 'mites. Trying to follow the Arduino codes given in SC & DIYODE mags is hard like you say.

Regards

ChopperP
ChopperP
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3308
Posted: 12:20pm 26 Mar 2018
Copy link to clipboard 
Print this post

  Chopperp said  Still not clear on why we have "Gosub Sub, Sub Label: & Return

Basically (as Grogs intimated) these are retained for backwards compatibility.

For example, many of these programs from the '80s will run on the Maximite/Micromite with only a few tweaks: http://www.vintage-basic.net/games.html
Geoff Graham - http://geoffg.net
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1106
Posted: 12:51pm 26 Mar 2018
Copy link to clipboard 
Print this post

Hi Geoff,
I was looking at the ON statement today & I assume that still needs the Gosubs

ChopperP
ChopperP
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3308
Posted: 02:03pm 26 Mar 2018
Copy link to clipboard 
Print this post

Yes it does (it is another legacy construct).

Why not use SELECT CASE ?
Geoff Graham - http://geoffg.net
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1106
Posted: 09:19pm 26 Mar 2018
Copy link to clipboard 
Print this post

Hi Geoff.
Should have mention I'm still on the CMM. Couldn't see SELECT CASE in the manual.
May have a look when I'm next playing with a uMite.

ChopperP

ChopperP
 
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