Menu
JAQForum Ver 19.10.27

Forum Index : Microcontroller and PC projects : MMBasic for Windows - betas

   Page 15 of 30    
Posted: 10:45am
21 Apr 2022
Copy link to clipboard
matherp
Guru

  Quote  Unfortunately this appears to be a regression from the previous build:


Don't think it is exactly the same bug and is all wrapped up in the problems with feof/ftell

In order for ftell to work I need to fflush before calling it. However, if I fflush when a file is opened but nothing has been written it seems to cause a problem. I really don't want to have to special case this everywhere. If you write before the eof call then it all works. Seems like a bug in stdlib to me. Calling fflush should be completely benign.
 
Posted: 11:05am
21 Apr 2022
Copy link to clipboard
thwill
Guru


  matherp said  
  Quote  Unfortunately this appears to be a regression from the previous build:


Don't think it is exactly the same bug and is all wrapped up in the problems with feof/ftell


Just in case we are talking at cross-purposes, the build I downloaded on 11th April "passes" all my MMBasic file I/O integration tests (perhaps some of the values returned by EOF are "wrong" but no unexpected errors are reported.)

The build I downloaded this morning fails one of those same tests with the error I reported.

So apparently you've made a change to fix something I wasn't aware of (didn't have an integration-test for) and "broken" something I did have an integration-test for (strictly speaking it was a test for something else that just happened to catch the change).

I'm not offering judgement (this business of calling EOF when writing a file is the very edge of an edge condition), just clarifying in case my bug report was misunderstood.

Best wishes,

Tom
 
Posted: 11:19am
21 Apr 2022
Copy link to clipboard
matherp
Guru

Please try the attached


MMBasic.zip

Might be OK or might have broken lots by introducing another special case
 
Posted: 01:32pm
21 Apr 2022
Copy link to clipboard
thwill
Guru


  matherp said  Please try the attached
MMBasic.zip
Might be OK or might have broken lots by introducing another special case


Sorry Peter, EOF seems to be borked now:
> list "eof_bug.bas"
Option Console Both

f$ = "new_file.txt"
On Error Skip
Kill f$

Open f$ For Output As #1
Print #1, "Hello World"
Close #1

Open f$ For Input As #1
Line Input #1, s$
Print s$
Print Eof(#1) ' Prints 1 on CMM2 and earlier versions of MMB4W
Close #1

> run "eof_bug.bas"
Hello World
0


Also you've left a diagnostic in that is printing "Flush" to the console.

Best wishes,

Tom
 
Posted: 02:01pm
21 Apr 2022
Copy link to clipboard
matherp
Guru

  Quote  EOF seems to be borked now:

Forgot the special case within the special case
MMBasic.zip
 
Posted: 02:19pm
21 Apr 2022
Copy link to clipboard
thwill
Guru


Improving:
> list "eof_bug.bas"
Option Console Both

Dim f$ = "new_file.txt"
On Error Skip
Kill f$

Print "This is 1 on the CMM2: " Eof(#0)

Open f$ For Output As #1
Print "This is 1 on the CMM2: " Eof(#1)
Print #1, "Hello World"
Print "This is 1 on the CMM2: " Eof(#1)
Close #1

Kill f$

Open f$ For Append As #1
Print "This is 1 on the CMM2: " Eof(#1)
Print #1, "Hello World"
Print "This is 1 on the CMM2: " Eof(#1)
Close #1
> run "eof_bug.bas"
This is 1 on the CMM2:  0
This is 1 on the CMM2:  1
This is 1 on the CMM2:  0
This is 1 on the CMM2:  1
This is 1 on the CMM2:  1


You might just want to check this on an actual CMM2 as I don't have one here with me and am extrapolating its behaviour from my integration tests.

Also note there is no guarantee my integration tests are comprehensive - infact I give you a cast iron guarantee that they are not!

Best wishes,

Tom
Edited 2022-04-22 00:28 by thwill
 
Posted: 06:59am
22 Apr 2022
Copy link to clipboard
matherp
Guru

V5.07.03b10


MMBasic.zip


Hopefully fixes the various issue found by Tom
 
Posted: 12:58pm
23 Apr 2022
Copy link to clipboard
thwill
Guru


  matherp said  Hopefully fixes the various issue found by Tom


It appears to, thank you.

Best wishes,

Tom
 
Posted: 07:22am
27 Apr 2022
Copy link to clipboard
Pluto
Guru

V5.07.03b10:
Running a testing program "Graftest.bas". OK  
Trying to save a copy of the program as "Graftest2.bas". NOK  




Program stored in the default MMBasic directory.
I am probably doing some stupid mistake. Need advice.

/Fred
 
Posted: 07:32am
27 Apr 2022
Copy link to clipboard
matherp
Guru

SAVE is not implemented as it has no logical use. Files are saved when exiting the editor or when using autosave. For your use you can use the copy command or the "save as" in the editor (ctrl-W)

NB - doesn't exist on CMM2 either as both implementations are "disk-based"
Edited 2022-04-27 17:34 by matherp
 
Posted: 08:27am
27 Apr 2022
Copy link to clipboard
Pluto
Guru

Thanks for the rapid reply!
I was confused by the MMBasic DOS/Windows Version User Manual
MMBasic Ver 5.05.05
p.24.
Maybe some clarifying note could be added in a future manual.
(Hopefully I have the newest manual in use?)
 
Posted: 08:45am
27 Apr 2022
Copy link to clipboard
matherp
Guru

There is no manual for the windows version of MMbasic - it is on the to-do list. The nearest is the CMM2 manual but ignore the I/O commands and functions
 
Posted: 12:24pm
27 Apr 2022
Copy link to clipboard
lizby
Guru

  Pluto said  I was confused by the MMBasic DOS/Windows Version User Manual MMBasic Ver 5.05.05 p.24.


MMBasic DOS (which has a manual) is different from MMBasic for Windows.
 
Posted: 12:21am
28 May 2022
Copy link to clipboard
disco4now
Guru


I have a Windows 10 laptop with Intel HD 530 graphics card. MMB4W has always been displayed strangely, (top line under window title, first character half off the screen) Variations of this with the different modes, only mode -16 really worked properly.

I finally update the driver for the graphics card from the Intel site and now its all good!!! Hope windows update doesn't downgrade it.
 
Posted: 09:28am
03 Jun 2022
Copy link to clipboard
thwill
Guru


Hi Peter,

I'm back on MMB4W for a couple of days, here's a bug for you that I'm suprised I didn't notice previously:



Observe that the hyphens passed from the prompt are not handled correctly (I'm guessing they are being converted into tokens), but those passed via EXECUTE are. I vaguely recollect that the CMM2 had the same issue but that you kindly fixed it for me.

Best wishes,

Tom
Edited 2022-06-03 19:28 by thwill
 
Posted: 09:49am
03 Jun 2022
Copy link to clipboard
thwill
Guru


And here is another one for you:



Observe the spurious newline that has been inserted as a result of throwing and skipping an ERROR.

Best wishes,

Tom
Edited 2022-06-03 19:56 by thwill
 
Posted: 10:42am
03 Jun 2022
Copy link to clipboard
matherp
Guru

Will fix first , the second is too obscure to waste time on - sorry
 
Posted: 11:59am
03 Jun 2022
Copy link to clipboard
thwill
Guru


  matherp said  Will fix first , the second is too obscure to waste time on - sorry


Pretty please .

I believe the offending line is in Commands.cpp:
void cmd_error(void) {
   char* s, p[STRINGSIZE];
   if (*cmdline && *cmdline != '\'') {
       s = (char *)getCstring(cmdline);
       if (CurrentX != 0) MMPrintString((char*)"\r\n"); // <<<<<<<<<<
       strcpy(p, s);
       error(p);
   }
   else
       error((char *)"");
}


IMO cmd_error() should not be printing anything directly, that should ony be occurring in the implementation of error() and even then only if not skipping errors.

Apologies that I can't fix/build/test myself and send you a patch. My Windoze machine requires an older Visual Studio tool-chain installed for the purposes of my dayjob and I'm not accomplished enough with the Windoze tools to get MMB4W building with it.

Best wishes,

Tom
Edited 2022-06-03 22:08 by thwill
 
Posted: 09:06am
28 Jun 2022
Copy link to clipboard
thwill
Guru


Good morning Peter,

Two more bugs/issues/observations. I suspect they are both also present on the CMM2 and the second issue may be endemic to MMBasic:

Issue 1 - fun with the pipe character

> list "pipe-bug.bas"
Print "Hello World"
Print "Goodbye|World" : Error "foo"
> run "pipe-bug.bas"
Hello World
Goodbye|World
Error in line 0: foo

and if you now start the EDITor it will have inserted a "line 0" into the file and then misbehave because it doesn't expect a line 0.

This happens because the | character has a special meaning in the tokenised form of MMBasic for MMB4W/MMB4L/CMM2 where it is used to delimit statement(s) from the metadata identifying the file/line they were sourced from.

Suggested remediation:
- Either, use strrchr() to search for the | character in reverse in the tknbuf.
- Or, ignore | chars in double-quotes when searching the tknbuf.

All bets are off if a .inc filename has the | character in it.

Issue 2 - fun with the DATA statement

Found this whilst trying to put quotation marks into a string in a DATA statement.

> list "data-bug.bas"
Dim i%, f!, s1$, s2$, s3$
Read i% : Print "i%" i%
Read f! : Print "f!" f!
Read s1$ : Print "s1$: '" s1$ "'"
Read s2$ : Print "s2$: '" s2$ "'"
Read s3$ : Print "s3$: '" s3$ "'"

Data 1 + 1, 3.0 + 0.142, wombat, "" + Chr$(34) + "foo", Chr$(34) + "bar"
> run
i% 2
f! 3.142
s1$ ''
s2$ 'wombat'
Error in line 9: Invalid character


This happens because READ/DATA handles integer and float expressions but has "unusual" handling for string variables, presumably to handle the legacy case of the unquoted string.

Suggested remediation:
- Either, remove legacy support for unquoted strings; easy for me to say since I don't use it.
- Or, if the first character in string data is a double-quote then treat it as a string expression, and accept the limitation that you must always start string data with a literal, even if it is the empty literal "".

Best wishes,

Tom

P.S. If you do "fix" either of these issue I would appreciate you telling me what fix you implement so that MMB4L can be adjusted accordingly.
Edited 2022-06-28 19:29 by thwill
 
Posted: 11:02am
30 Jun 2022
Copy link to clipboard
thwill
Guru


Hi Peter,

I know MMB4W is a bit of a Cinderella at the moment, but here is another strange one for you:

> list "odd-bug.bas"
Dim test$ = foo$()
test$ = foo$()
Function foo$()
End Function
> run "odd-bug.bas"
0
>


I can't see any reason for this to output "0", and if you change the variable name from test$ it doesn't happen !!!

Best wishes,

Tom
 
   Page 15 of 30    
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025