Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:29 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 8 of 30    
Author Message
matherp
Guru

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

  Quote  Just got some time to play with this (03.b5), and it seems that there's something with fonts: in command line, as soon as I enter something invalid the font reverses to default:


This is intentional. There are lots of things you can do which mean the error message could be illegible (e.g. font of symbols). Therefore all errors default the font
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 830
Posted: 08:16am 09 Mar 2022
Copy link to clipboard 
Print this post

@Matherp:
  Quote  
You need to copy them to Windows/system32

What CPU do you have?


Damn Windows says that I have no rights to copy the files to System32 - even though I'm logged in as admin. The files are already there. Normally Windows takes the DLL's which are in the folder of the called program - even if they are already in System32...

The processor is a Intel I7.

Frank
 
matherp
Guru

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

Frank

Are you going to be online for a while? If so I'll post some hack versions for you to test to see if we can isolate the problem
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 651
Posted: 10:22am 09 Mar 2022
Copy link to clipboard 
Print this post

G'Day All

I installed onto LINUX (ZORIN) with no problems but no luck with W7 or W10 on 2 different PCs. So while I thought about it I noticed the windows in the back room were dirty so I cleaned them. After that W10 came good. W7 is still out but it is in another room so perhaps I need to clean more windows. I know this is all a bit silly but it does indicate some instability in me or W10 or BASIC or ????
Good luck, you blokes are all much too clever for me.

Peter
 
thwill

Guru

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

Good morning Peter, here is some more food for thought:

1. Should TIMER be initialised to 0 when MMB4W is launched? that would be a closer simulation of the CMM2.

2. Can I suggest you trim whitespace from the output of the SYSTEM command when you capture it in a LONGSTRING. The output usually ends CRLF which is no use to man nor beast. You might also consider having the option to capture the output in a regular String as that is often both sufficient and more convenient.

3. The CMM2 allows a non-existing SEARCH PATH to be specified whereas MMB4W does not. I think the behaviour of MMB4W is correct, and is what I implemented independently for MMB4L.

4. The format of error messages is different between the CMM2 and MMB4W:

On Error Skip 1
Error "foo"
Print "MSG: " Mm.ErrMsg$, Mm.ErrNo
Error "bar"

CMM2 output:
> run
MSG: Error in line 2: foo        16
Error in line 4: bar
<newline>

MMB4W output:
> run
MSG: foo    16
bar


For what it's worth MMB4L does what the CMM2 does but without the trailing <newline>.

YMMV but in my ideal world an uncaught error would display the line number, but when an error is caught Mm.ErrMsg$ would not include the line number which would instead be available separately from an MM.INFO(ERRLINE).

Best wishes,

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

Guru

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

5. This one has been getting on my goat too and I've finally managed to reproduce it simply:



Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 830
Posted: 11:24am 09 Mar 2022
Copy link to clipboard 
Print this post

@Matherp:

Thanks for your effort! I am online.

Frank
 
matherp
Guru

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

Frank

Please try the attached. Current version but with audio disabled


ForFrank.zip
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 830
Posted: 12:01pm 09 Mar 2022
Copy link to clipboard 
Print this post

This version works!!!


Frank
 
matherp
Guru

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

OK so we know it is the audio dll which is the problem - winmm.dll

Now please try the attached but launch mmbasic from a dos box using the command
MMBASIC 0



MMBasic.zip

Tom:

This should fix your issues including allowing a string variable for system except for getting rid of whitespace on the system command - what do you mean by whitespace?
Edited 2022-03-09 22:37 by matherp
 
thwill

Guru

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

  matherp said  Tom:

This should fix your issues including allowing a string variable for system except for getting rid of whitespace on the system command


Thanks, will test tomorrow.

  Quote  - what do you mean by whitespace?


Spaces, tabs, CRLF, other garbage at the end of the SYSTEM output, YMMV but invariably I end up having to manually remove this.

As an example call:
   SYSTEM("echo %time%", ls%()
and you will find ls%() ends with a CRLF pair which is just inconvenient.

Anyway, for your consideration here is the corresponding code from MMB4L:
/**
* Executes a system command and captures its STDOUT in a buffer.
*
* @param  cmd  system command to execute.
* @param  buf  buffer to capture output in, this will not be '\0' terminated.
* @param  sz   on entry size of buffer,
*              on return number of characters in buffer.
* @return      exit code of the executed system command.
*/
static int cmd_system_capture(char *cmd, char *buf, size_t *sz) {
   FILE *f = popen(cmd, "r");
   error_check();

   int i;
   for (i = 0; i < *sz; ++i) {
       int ch = fgetc(f);
       if (ch == EOF) break;
       buf[i] = (char) ch;
   }

   // Trim trailing whitespace and non-ASCII garbage.
   while (buf[i] < 33 || buf[i] > 126) i--;

   *sz = i + 1;

   return pclose(f);
}


On reflection I do wonder if there are use-cases where the caller will want that "garbage" but I think they are in the minority and would be better served by an additional flag/argument to SYSTEM to request the "raw" output.

Best wishes,

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

Guru

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

  thwill said  On reflection I do wonder if there are use-cases where the caller will want that "garbage" but I think they are in the minority and would be better served by an additional flag/argument to SYSTEM to request the "raw" output.


I continue to reflect. I've convinced myself that stripping all trailing non-ASCII is probably a bad idea (consider running on a language localized version of Windows). I'm now thinking it would be best to trim 'ch' if (!isprint(ch) || isspace(ch)) and even then I wonder about using SYSTEM to run a command that writes unicode to its output.

Best wishes,

Tom
Edited 2022-03-09 23:35 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 830
Posted: 01:43pm 09 Mar 2022
Copy link to clipboard 
Print this post

@Matherp:

Ok, with "MMBASIC 0" it works, without it does not work.

Frank
 
matherp
Guru

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

  Quote  Ok, with "MMBASIC 0" it works, without it does not work.

The only difference is that with the 0 I don't enable audio. That confirms the issue so you will need to find a version of winmm.dll that works and get it into the correct place or just do without audio (I'll leave the 0 parameter in place permanently) . I can't help any further - sorry

  Quote  I continue to reflect.

I'm just going to leave as-is. In any case the system command is much less useful on Windows than Linux as it isn't a command line operating system
Edited 2022-03-09 23:50 by matherp
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 830
Posted: 01:55pm 09 Mar 2022
Copy link to clipboard 
Print this post

@Matherp:

Thanks again for your efforts! I think I can live with "MMBASIC 0" and audio turned off...

Frank
 
Plasmamac

Guru

Joined: 31/01/2019
Location: Germany
Posts: 554
Posted: 03:05pm 09 Mar 2022
Copy link to clipboard 
Print this post

Will this work with win 7?
Plasma
 
electricat

Senior Member

Joined: 30/11/2020
Location: Lithuania
Posts: 161
Posted: 03:41pm 09 Mar 2022
Copy link to clipboard 
Print this post

With audio disabled version, It works on WIN7
(2022-03-09_215232_ForFrank.zip)
Edited 2022-03-10 01:43 by electricat
 
matherp
Guru

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

V5.07.03b6


MMBasic.zip

This version tidies up launching MMBasic while allowing audio to be turned off if required

Valid uses are:


MMBASIC 'opens MMBasic
MMBASIC "program.bas" ' opens MMBasic and immediately runs program.bas
MMBASIC "program" ' opens MMBasic and immediately runs program.bas
MMBASIC "program.bas",text ' opens MMBasic and immediately runs program.bas, passes text to the program as MM.CMDLINE$
MMBASIC "program",text ' opens MMBasic and immediately runs program.bas, passes text to the program as MM.CMDLINE$
MMBASIC  0 'opens MMBasic with audio disabled
MMBASIC 0 "program.bas" ' opens MMBasic and immediately runs program.bas with audio disabled
MMBASIC 0 "program" ' opens MMBasic and immediately runs program.bas with audio disabled
MMBASIC 0 "program.bas",text ' opens MMBasic and immediately runs program.bas, passes text to the program as MM.CMDLINE$ with audio disabled
MMBASIC 0 "program",text ' opens MMBasic and immediately runs program.bas, passes text to the program as MM.CMDLINE$ with audio disabled


Note the comma after the filename if passing data to the basic program. This is essential if the data is to be passed. To pass data with spaces in it enclose it in quotes.
Note the space after the 0. This is essential if you want to run aprogram immediately
Note if audio is disabled the PLAY command and GUI BEEP will return immediately without doing anything
Edited 2022-03-10 03:04 by matherp
 
Michal
Senior Member

Joined: 02/02/2022
Location: Poland
Posts: 123
Posted: 05:14pm 09 Mar 2022
Copy link to clipboard 
Print this post

Hi matherp,

How to stop LIST execution?
Could this MMBASIC 0 option not be included in the initial configuration?

Michal
 
matherp
Guru

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

  Quote  How to stop LIST execution?

CTRL-C
  Quote  Could this MMBASIC 0 option not be included in the initial configuration?

The capability will be available in all future releases but the default will be full functionality with audio
Edited 2022-03-10 04:31 by matherp
 
     Page 8 of 30    
Print this page
© JAQ Software 2024