Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:31 27 Nov 2024 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 for Windows - betas

     Page 11 of 30    
Author Message
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 358
Posted: 07:51pm 20 Mar 2022
Copy link to clipboard 
Print this post

After all it is up to anyone of us here on the forum to follow the developments and eventually learn something new or to do something else.
I am personally not in any means an expert in microcontrollers or programming, but I have found the MMBasic to be an interesting, userfriendly and stright forward environment for many (in my eyes) interesting projects. Idea to functioning gadget in a few minutes...to hours. Something I could not even think about with other programming environments that I am aware of. Prior to MMbasic I used Flowcode, which I immediately skippped after getting to know MicroMite. Furthermore MMBasic is free of charge with extremely rapid response from "customer service".

I have only been a member for a few years. I admit that I might have missed some earlier membership requirements about required professionalism and competence for being here. Sorry for that!
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 847
Posted: 03:34am 21 Mar 2022
Copy link to clipboard 
Print this post

For Peter,

A trivial glitch but missing a closing " when printing text appears to not throw up an error (and I can't see how MMBasic could tell it was an error rather than intended, unless it counted "s in each line?).

eg:
PRINT "Text

prints:

Text

Only really an issue in say:
PRINT "Text, A, B, C

which prints:
Text, A, B, C

Where you might want to print the values of A, B & C

Cheers,

Andrew
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 05:33am 21 Mar 2022
Copy link to clipboard 
Print this post

I think that is a general MMBasic 'feature'. I've seen it in other people's programs before and just tested it on the original MMBasic for windows and on a Micromite.

Bill
Keep safe. Live long and prosper.
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 847
Posted: 05:47am 21 Mar 2022
Copy link to clipboard 
Print this post

Thanks Bill,
Yes it is probably something to watch out for rather than leaving it to MMBasic.
I've packed my 'mites away so I can't test but I suspect that MMEdit, which I use a lot, catches it before it gets to MMBasic.

Cheers,

Andrew
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 05:51am 21 Mar 2022
Copy link to clipboard 
Print this post

Well MMEdit certainly makes it look more obvious.

Bill
Keep safe. Live long and prosper.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 06:03am 21 Mar 2022
Copy link to clipboard 
Print this post

If memory serves, this has always been the case in all versions. If you omit the closing " it is assumed to be at the end of the line.
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 06:50am 21 Mar 2022
Copy link to clipboard 
Print this post

  Andrew_G said  A trivial glitch but missing a closing " when printing text appears to not throw up an error

This has been a "feature" of MMBasic since the early days.  The interpreter knows that all quotes must be closed and if it has not detected the closing quote at end of line it will insert it for you.  From what I can remember Peter had to remove that function from the CMM2 version for some reason but it is in almost every other version.

It was intended as a convenience feature but, as you point out, it can lead to confusing behaviour.

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

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 06:55am 21 Mar 2022
Copy link to clipboard 
Print this post

  Geoffg said  it can lead to confusing behaviour

Maybe but easy enough to sort out.

Bill
Keep safe. Live long and prosper.
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 847
Posted: 07:40am 21 Mar 2022
Copy link to clipboard 
Print this post

Thanks Geoff, Bill, Phil
- yep MMBasic can only do so much hand-holding - we have to be trusted to check some things . . .

Cheers,

Andrew
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4042
Posted: 10:49am 21 Mar 2022
Copy link to clipboard 
Print this post

Good morning Peter,

The unit-tests are looking good:
> *sptest                                                                                                              
Building list of tests ...
Executing tests ...
C:\home-thwill\git_sandbox\github\cmm2-saaint-public\src\tests\tst_interp.bas --all  PASS (27/27)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\gonzo\tests\tst_console.bas --all PASS (3/3)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\gonzo\tests\tst_console.bas --all --base=1 PASS (3/3)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\spflow\tests\tst_cmdline.bas --all PASS (10/10)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\spflow\tests\tst_options.bas --all PASS (6/6)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\spflow\tests\tst_process.bas --all PASS (4/4)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_array.bas --all   PASS (8/8)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_array.bas --all --base=1 PASS (8/8)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_bits.bas --all    PASS (3/3)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_bits.bas --all --base=1 PASS (3/3)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_crypt.bas --all   PASS (9/9)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_crypt.bas --all --base=1 PASS (9/9)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_file.bas --all    PASS (17/17)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_file.bas --all --base=1 PASS (17/17)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_inifile.bas --all PASS (6/6)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_inifile.bas --all --base=1 PASS (6/6)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_list.bas --all    PASS (12/12)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_list.bas --all --base=1 PASS (12/12)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_map.bas --all     PASS (14/14)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_map.bas --all --base=1 PASS (14/14)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_math.bas --all    PASS (1/1)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_math.bas --all --base=1 PASS (1/1)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_set.bas --all     PASS (11/11)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_set.bas --all --base=1 PASS (11/11)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_string.bas --all  PASS (10/10)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_string.bas --all --base=1 PASS (10/10)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_system.bas --all  PASS (5/5)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_system.bas --all --base=1 PASS (5/5)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_vt100.bas --all   PASS (3/3)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\splib\tests\tst_vt100.bas --all --base=1 PASS (3/3)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\sptrans\tests\tst_cmdline.bas --all PASS (16/16)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\sptrans\tests\tst_lexer.bas --all PASS (22/22)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\sptrans\tests\tst_options.bas --all PASS (11/11)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\sptrans\tests\tst_pprint.bas --all PASS (20/20)
C:\home-thwill\git_sandbox\github\cmm2-sptools\src\sptrans\tests\tst_trans.bas --all PASS (5/5)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_call.bas --all                 PASS (2/2)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_call.bas --all --base=1        PASS (2/2)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_data.bas --all                 PASS (8/8)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_data.bas --all --base=1        PASS (8/8)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_file_fns.bas --all             PASS (16/16)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_file_fns.bas --all --base=1    PASS (16/16)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_fundamentals.bas --all         PASS (5/5)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_fundamentals.bas --all --base=1 PASS (5/5)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_inc.bas --all                  PASS (8/8)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_inc.bas --all --base=1         PASS (8/8)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_json.bas --all                 PASS (1/1)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_json.bas --all --base=1        PASS (1/1)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_longstring.bas --all           PASS (20/20)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_longstring.bas --all --base=1  PASS (20/20)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_math.bas --all                 PASS (21/21)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_math.bas --all --base=1        PASS (21/21)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_memory.bas --all               PASS (13/13)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_memory.bas --all --base=1      PASS (13/13)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_mminfo.bas --all               PASS (29/29)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_mminfo.bas --all --base=1      PASS (29/29)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_peek.bas --all                 PASS (10/10)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_peek.bas --all --base=1        PASS (10/10)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_poke.bas --all                 PASS (7/7)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_poke.bas --all --base=1        PASS (7/7)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_simple_maths_fns.bas --all     PASS (9/9)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_simple_maths_fns.bas --all --base=1 PASS (9/9)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_sort.bas --all                 PASS (20/20)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_sort.bas --all --base=1        PASS (20/20)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_static.bas --all               PASS (1/1)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_static.bas --all --base=1      PASS (1/1)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_strings.bas --all              PASS (5/5)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_strings.bas --all --base=1     PASS (5/5)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_system.bas --all'foo bar'
'foo' is not recognized as an internal or external command,
operable program or batch file.
              PASS (10/10)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_system.bas --all --base=1'foo bar'
'foo' is not recognized as an internal or external command,
operable program or batch file.
     PASS (10/10)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_time_fns.bas --all             PASS (8/8)
C:\home-thwill\git_sandbox\github\mmb4l-src\tests\tst_time_fns.bas --all --base=1    PASS (8/8)
Total execution time: 10 s


Hopefully I can persuade you to try and deal with the "mess" at the bottom (only appears on the "serial" console), but you probably aren't that bothered since it is coming from the SYSTEM command.

Try this:
> list "system_bugs.bas"
Option Console Both

Dim s$

' SYSTEM capture with a string (but not longstring) variable
' appends an unexpected 0 to the result.
System "echo 'foo bar'", s$
Print Len(s$) " should be 11"
Print Peek(Var s$, 10) Peek(Var s$, 11) Peek(Var s$, 12)

' SYSTEM with an unknown command doesn't report an error that the user can
' see/capture, though it does dump an error message to the serial console.
s$ = ""
On Error Clear
On Error Skip 1
System "no-such-command", s$
Print "Mm.ErrMsg$ = " Choice(Mm.ErrMsg$ = "", "<none>", Mm.ErrMsg$)
Print "Mm.ErrNo   = " Mm.ErrNo

' On my system this outputs {'}, where is the apostrophe coming from?
Print "{" s$ "}", Len(s$)

> run "system_bugs.bas"
12 should be 11
10 13 0
'no-such-command' is not recognized as an internal or external command,
operable program or batch file.
Mm.ErrMsg$ = <none>
Mm.ErrNo   =  0
{'}      1


1. In my opinion at the very least the unexpected '0' in the captured string output from SYSTEM should be dealt with.

2. Can I try and persuade you again to trim the CRLF from the captured output ? This will be the last time I ask.

On a completely unrelated matter if MMB4W's primary purpose is as a "simulation" of the CMM2 - and I think that is an eminently sensible and worthwhile purpose - then is there any chance you can be persuaded to do something about supporting (ignoring?) the MAP command as pretty much all of the graphical examples on The Welcome Tape fall-over because it's an unrecognised command.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9122
Posted: 12:37pm 21 Mar 2022
Copy link to clipboard 
Print this post

Tom

Thanks for the testing.

1. will fix

  Quote   Can I try and persuade you again to trim the CRLF from the captured output ?


I though you changed your mind on this? What about embedded CR/LF as in "DIR"?

  Quote  SYSTEM with an unknown command doesn't report an error that the user can
see/capture,


Don't know how to do this. _popen returns a valid address and errno isn't set even when the command is invalid

  Quote  is there any chance you can be persuaded to do something about supporting (ignoring?) the MAP command


I've thought about this and didn't see an easy way of doing it - will have another think
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4042
Posted: 12:53pm 21 Mar 2022
Copy link to clipboard 
Print this post

Hi Peter,

  matherp said  
  Quote   Can I try and persuade you again to trim the CRLF from the captured output ?


I though you changed your mind on this? What about embedded CR/LF as in "DIR"?


I changed MMB4L so that it will just remove any final trailing CR, LF or CRLF pair. It doesn't trim anything else, embedded or otherwise.

  matherp said  
  Quote  SYSTEM with an unknown command doesn't report an error that the user can
see/capture,


Don't know how to do this. _popen returns a valid address and errno isn't set even when the command is invalid


Check the return value from _pclose().

You might also want to consider automatically appending "2>&1" to the command executed so that STDERR is redirected to STDOUT and can thus be captured in the stream returned by _popen().

See https://github.com/thwill1000/mmb4l-src/blob/thwill-alpha4/linux-src/commands/cmd_system.c which now also includes code to capture the exit status of the executed program and sub-commands SYSTEM GETENV and SYSTEM SETENV - YMMV.

  matherp said  
  Quote  is there any chance you can be persuaded to do something about supporting (ignoring?) the MAP command


I've thought about this and didn't see an easy way of doing it - will have another think


Thanks, I think it's a missing link in the "Simulation" and worth addressing even if difficult and not strictly necessary because Windows doesn't have the colour/resolution limitations of the CMM2 hardware.

Best wishes,

Tom
Edited 2022-03-21 23:39 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4042
Posted: 01:04pm 21 Mar 2022
Copy link to clipboard 
Print this post

Peter,

Just a note that popen() and pclose() isn't really the "Windows way", you're using the POSIX compatibility layer.

If you want to bite the bullet then:

https://docs.microsoft.com/en-us/windows/win32/procthread/creating-a-child-process-with-redirected-input-and-output

But I'm almost as much in the dark as you are when it comes to that.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3802
Posted: 02:37pm 21 Mar 2022
Copy link to clipboard 
Print this post

  thwill said  You might also want to consider automatically appending "2>&1" to the command executed

Is it intelligent so that if the user already redirects stderr then the above isn't added?

  thwill said  See https://github.com/thwill1000/mmb4l-src/blob/thwill-alpha4/linux-src/commands/cmd_system.c

Page not found :(

John
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4042
Posted: 02:49pm 21 Mar 2022
Copy link to clipboard 
Print this post

  JohnS said  
  thwill said  You might also want to consider automatically appending "2>&1" to the command executed

Is it intelligent so that if the user already redirects stderr then the above isn't added?


MMB4L isn't that intelligent yet, though it is marked as a TODO. Given the niche usage and the zero users I didn't think it was that important to fix now.

Long term I will probably want to stop using popen() which can only capture STDOUT and use the lower-level fork() instead so I can redirect STDOUT and STDERR independently without resorting to this hack.

  JohnS said  
  thwill said  See https://github.com/thwill1000/mmb4l-src/blob/thwill-alpha4/linux-src/commands/cmd_system.c

Page not found :(


Sorry John, it's a private GitHub repository which Peter can see as he is listed as a collaborator. If you have a GitHub username then I'm happy to add you as a collaborator too provided you have previously agreed to Geoff's license terms for access to the MMBasic source code - PM me.

Or wait for a month or two when MMB4L alpha 4 will be released as open-source and I will make the repository public.

Best wishes,

Tom
Edited 2022-03-22 00:52 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3802
Posted: 05:25pm 21 Mar 2022
Copy link to clipboard 
Print this post

No worries. It'll keep!

John
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4042
Posted: 10:34am 22 Mar 2022
Copy link to clipboard 
Print this post

Hi Peter,

Having got my unit-tests working I've returned back to trying to get SAAINT running in MMB4W and have run across this interesting bug:

> list "bug.bas"                                                                
Option Console Serial
Option Console Both
Option Console Screen

Print "Hello Peter"

Select Case 1
 Case 1 : Option Console Serial
End Select

Print "Goodbye Peter"
>
> run "bug.bas"
Hello Peter
Only valid in a program


Obviously this nonsense has been pared down to the bare minimum, the real code does make sense, honest! It does run on the CMM2 and MMB4L.

The issue here is that OPTION CONSOLE SERIAL does work in a program (line 1) but when called from within the SELECT CASE construct it reports this strange "Only valid in a program" error.

Additionally unlike the CMM2 the TRACE LIST command (and presumably the whole of the TRACE framework) just reports line numbers and not the .inc file they correspond to.

Best wishes,

Tom
Edited 2022-03-22 20:56 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9122
Posted: 11:48am 22 Mar 2022
Copy link to clipboard 
Print this post

  Quote  and have run across this interesting bug:

The workround is to put the OPTION on a separate line from the case. This is deep in MMbasic and I'm not going to touch it. Have a look at the code for CMD_SELECT and you will see why it occurs. From what I can remember this isn't the only oddity about putting statements on the same line as the CASE perhaps the manual should warn against it or we should even error it

Will fix TRACE
Edited 2022-03-22 21:52 by matherp
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4042
Posted: 11:55am 22 Mar 2022
Copy link to clipboard 
Print this post

  matherp said  
  Quote  and have run across this interesting bug:

The workround is to put the OPTION on a separate line from the case. This is deep in MMbasic and I'm not going to touch it. Have a look at the code for CMD_SELECT and you will see why it occurs. From what I can remember this isn't the only oddity about putting statements on the same line as the CASE perhaps the manual should warn against it or we should even error it.


Interesting, works "as-is" on the CMM2 and MMB4L.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9122
Posted: 12:02pm 22 Mar 2022
Copy link to clipboard 
Print this post

It won't work on anything that tests for CurrentLinePtr

This does the same on CMM2

select case 1
case 1:option y_axis up
end select
Edited 2022-03-22 22:04 by matherp
 
     Page 11 of 30    
Print this page
© JAQ Software 2024