Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:43 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 : MMBasic wut?

Author Message
grawlix
Newbie

Joined: 29/04/2025
Location: United States
Posts: 8
Posted: 04:33am 11 May 2025
Copy link to clipboard 
Print this post

I've spotted a bit of weirdness in an MMBasic program, and though I could stand some edification.  As near as I can tell, this is a good spot to talk about this retrowonder--my apologies if I'm misguided.

I'm using Peter Mather's version 5.07.03b24 build for Windows.

Here's the code:

Option Explicit

Dim M As Integer = 2.5
Dim N As Integer = 3.7

Print M, N
Wut M, N
Wut (M), (N)

Sub Wut(Em As Float, En As Float)
 Print Em, En
End Sub


And the execution...

> run
3   4
3   4
3   0


Why does that second argument get wrecked when I pass it by value?  I'm assuming it has something to do with the implicit typecast, but the first argument passes in that  circumstance.  

I just want to follow up on that Option Explicit, by specifically thanking everyone involved in MMBasic's production through all time, past and future.  It has healed some early childhood trauma had while forcing a TRS-80 Model 4 to produce color graphics.  Thank you.
 
Peter63
Regular Member

Joined: 28/07/2017
Location: Sweden
Posts: 54
Posted: 05:35am 11 May 2025
Copy link to clipboard 
Print this post

Hi, grawlix

I tried this program in PicoMiteVGA MMBasic USB RP2040 Edition V6.00.02RC10 and got the same result. I tested enclosing everything in parentheses.
Like this:
Wut((M), (N))

Then I got the correct result.

For me, it was natural to embrace it with parentheses but I don't know if the syntax should be different...

/Peter63
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3281
Posted: 10:35am 11 May 2025
Copy link to clipboard 
Print this post

In MMBasic the parameter list can be surrounded by parentheses or not. So both Wut M, N and Wut(M, N) are valid.

In the line of code that does not work the interpreter has spotted the opening parentheses after the subroutine name and assumed that the second version (list surrounded by parentheses) is being used.  It then searched for the closing parentheses and ignored the rest of the statement.  So, the function call is interpreted as Wut(M).

It would be good if MMBasic issued a warning about the ignored text but MMBasic started on devices that had limited flash, so it was impossible to detect all potential misunderstandings between the programmer and the interpreter.  It would have been even better if I had not implemented the second version (Wut(M, N)) at all.  But once something is implemented you cannot remove it for fear of breaking someone's code.

Geoff
Geoff Graham - http://geoffg.net
 
grawlix
Newbie

Joined: 29/04/2025
Location: United States
Posts: 8
Posted: 12:51pm 11 May 2025
Copy link to clipboard 
Print this post

Understood.  Thank you for the explanation, my speculations were way off.  I should have tried the code without any typecasting.

I'm new to the forum, and can't see how to upvote, applaud, celebrate or animate my gratitude for your reply, so I'll stick with words:  Thank you so much for what you, and others, have done with MMBasic.  

Kemeny's vision, if I'm to believe the documentaries, was that programming should be a tool, not just a philosophical distraction for the academic.  Programming should be useable in all fields of inquiry.  

I believed it in the 1980s, without knowing anything about him, and wrote many BASIC programs on my TRS-80 Model 100 to rip through tedious lab write-ups.  Until recently, I moaned about the good old days when you turned a computer on, and you only had to wait for the tube to warm up before you could start programming BASIC.

Thank you.
 
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