Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 13:35 20 Apr 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 : CMM2: V5.06.00b4: More "fun" functionality for testing

     Page 3 of 3    
Author Message
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1094
Posted: 12:24am 27 Nov 2020
Copy link to clipboard 
Print this post

  thwill said  
  panky said  ... If you want what remains on the screen from one program to be available for some later program ...


Please note I don't want it to "be available for some later program", I want it to be available for the USER.

If I implement "find", "grep" and "count", then as a USER I don't want the screen to clear between each of the commands:

*find "*.bas" > "out.txt"
*grep "foo" < "out.txt" > "out2.txt"
*count < "out2.txt"


In this example no program is relying on the screen output by the previous program, data is exchanged via files, however the USER experience is greatly improved if they can see all the "commands" they've issued.

Note I'm aware that the BASIC "shell" doesn't implement redirection; you have to build it into each programs separately.

Best wishes,

Tom


Tom, I understand now what it is you were considering. I would love to have some mechanism in MMBasic to allow the console output to be available for other commands/programs along the lines you have indicated or at least copied to a file for further processing by other routines or programs.

I realise that this is not Basic, but it would be nice if the OPTION CONSOLE could be extended to allow textual data that is the normal console output to be directed to either a file, such as OPTION CONSOLE PIPE "filename" which would be automatically closed at program end or closed explicitly with OPTION CONSOLE PIPE CLOSE, or to some dynamically defined buffer like the console receive buffer.

In my case, this would be very usefull for collecting TRACE data or LIST PAGES data or in fact any utilities that send large amounts of text out to the console ( which unfortunately in a standalone operation just 'gets lost').

Yes, I know with a PC you can catch this with TeraTerm or GFXTerm but that is no good when standalone and yes, I know you can PRINT to a file but there are a number of other commands that just send output to the screen(console) without the ability to re-direct to a file.

Not a request as such, just my 2 penneth worth.

Doug.
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3831
Posted: 12:50pm 27 Nov 2020
Copy link to clipboard 
Print this post

  panky said  Tom, I understand now what it is you were considering. I would love to have some mechanism in MMBasic to allow the console output to be available for other commands/programs along the lines you have indicated or at least copied to a file for further processing by other routines or programs ...


Your suggestions sound reasonable to me, but I respect @matherp as the arbiter and implementer, in general good suggestions are accepted, if not always on the first attempt.

As it stands, even without these, I believe a functional virtual operating system (see https://en.wikipedia.org/wiki/Software_tools_users_group) can be built upon MMBasic, even issues with capturing TRACE can probably be solved through a CSUB and ingenuity.

The one "big item" that I think is missing is an inbuilt/firmware mechanism by which when the current BASIC program ends (even with an error) control is handed off to another BASIC program instead of to the BASIC command prompt, I believe this is a prerequisite for writing a decent "shell" program. Let's just say @matherp was not receptive .

That said I'm not pushing this. The tool development I'm doing is for my own benefit and going slowly due to lack of time. If/when I have something worth sharing I do. If I ever find myself having implemented most of a "shell" then I'll try to persuade @matherp to provide the final building blocks, and I suspect he will be more receptive when he can see a concrete benefit.

Best wishes,

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

Joined: 18/11/2011
Location: United Kingdom
Posts: 3649
Posted: 01:04pm 27 Nov 2020
Copy link to clipboard 
Print this post

  thwill said  The one "big item" that I think is missing is an inbuilt/firmware mechanism by which when the current BASIC program ends (even with an error) control is handed off to another BASIC program instead of to the BASIC command prompt

That sounds like the autorun feature.

John
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3831
Posted: 01:23pm 27 Nov 2020
Copy link to clipboard 
Print this post

  JohnS said  
  thwill said  The one "big item" that I think is missing is an inbuilt/firmware mechanism by which when the current BASIC program ends (even with an error) control is handed off to another BASIC program instead of to the BASIC command prompt

That sounds like the autorun feature.

John


It does "sound" like that, but IIRC when I originally investigated it doesn't quite work that way, something to do with the behaviour of the watchdog timer. Anyway it's not something I'm pursuing for the moment, I was just shooting the breeze.

Best wishes,

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

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3831
Posted: 11:30am 28 Nov 2020
Copy link to clipboard 
Print this post

Hi Peter,

Unfortunately SORT still has at least one bug:

Colour Maximite 2
MMBasic Version 5.06.00b6
Copyright 2011-2020 Geoff Graham
Copyright 2016-2020 Peter Mather

> list "bug.bas"
Option Base 0
Option Explicit On
Option Default None

Dim data$(4) = ("one", "two", "three", "four", "five")

Sort data$(), , , 0, 5

> run "bug.bas"
Error in line 7: 5 is invalid (valid is 0 to 4)


As far as I can see 5 is a perfectly valid number of elements to sort, i.e. sort all the elements.

Best wishes,

Tom
Edited 2020-11-28 21:31 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8567
Posted: 11:37am 28 Nov 2020
Copy link to clipboard 
Print this post

The code assumes the last "optional" parameter will only be specified if you want to cut the size of the sort and checks accordingly
Edited 2020-11-28 21:37 by matherp
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3831
Posted: 11:46am 28 Nov 2020
Copy link to clipboard 
Print this post

  matherp said  The code assumes the last "optional" parameter will only be specified if you want to cut the size of the sort and checks accordingly


If I can so be bold, "that's a mistake". It means that any client code that might need to sort a variable number of elements in an array will have handle SORTing all the elements as a special case.

EDIT: IMO It's also inconsistent:

Print Mid$("foo", 1, 3)

Doesn't report an error: 3 is invalid (valid is 0 to 2).

Best wishes,

Tom
Edited 2020-11-28 21:49 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8567
Posted: 11:49am 28 Nov 2020
Copy link to clipboard 
Print this post

  Quote  It means that any client code that might need to sort a variable number of elements in an array will have handle SORTing all the elements as a special case.


It will anyway as you would get an error if you ask for more elements than the array size
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3831
Posted: 11:51am 28 Nov 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  It means that any client code that might need to sort a variable number of elements in an array will have handle SORTing all the elements as a special case.


It will anyway as you would get an error if you ask for more elements than the array size


True, but that is actually an error.

How about this argument, what you've implemented is inconsistent:

Print Mid$("foo", 1, 3)


Doesn't report an error: 3 is invalid (valid is 0 to 2).

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

Joined: 18/11/2011
Location: United Kingdom
Posts: 3649
Posted: 11:55am 28 Nov 2020
Copy link to clipboard 
Print this post

3 looks valid to me!

John
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3831
Posted: 11:57am 28 Nov 2020
Copy link to clipboard 
Print this post

Also if we follow your logic regarding optional parameters only being specified when useful then:

Dim data$(4) = ("one", "two", "three", "four", "five")

Sort data$(), , , 0


Should report the error: 0 is invalid (valid is 1 to 4)



Tom
Edited 2020-11-28 21:57 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3831
Posted: 12:05pm 28 Nov 2020
Copy link to clipboard 
Print this post

  JohnS said  3 looks valid to me!

John


Absolutely! But not by the argument Peter used to support his decision to not allow the last parameter in SORT to be the size of the whole array being sorted.

Tom
Edited 2020-11-28 22:05 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3831
Posted: 12:09pm 28 Nov 2020
Copy link to clipboard 
Print this post

Anyway I probably shouldn't have tried to make a "clever" argument, you probably just think I'm being a jerk.

@matherp is there any good reason to not support code calling SORT to sort an entire array whilst specifying all optional parameters.

Best wishes,

Tom
Edited 2020-11-28 22:10 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 324
Posted: 12:23pm 28 Nov 2020
Copy link to clipboard 
Print this post

  matherp said  V5.06.00b6

Now onto the video clearing issue -
The purist in me (and despite the way I develop I am at heart a purist   ) says everything should be cleared when you run a new program and many (including Geoff) agree. However, I do understand Tom's point of view.
In this release all video pages except page 0 are cleared when you run a program and the x and y positions are not changed. Any mode change will of course clear page 0 but if you run a program in the same mode as the default (OPTION DEFAULT MODE) then it will be up to you to clear the screen.
I hope this is a compromise everyone can accept.

Note: this version runs a little faster than previous versions. There is precisely no reason for this. Every time I compile some combination of the compiler optimisation and the way that caching works in the processor seems to yield a very slightly different result.


Traditionally, BASIC has cleared all variables when RUNning a program unlike some other languages where you can't count on a variable's contents (no pun!) when accessing it for the first time. Leaving the screen alone between runs is a good thing to do. Thanks!
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3831
Posted: 01:20pm 28 Nov 2020
Copy link to clipboard 
Print this post

Hopefully this one is immune to argument:
> list "bug.bas"
Option Base 1 ' *** NOTE THIS
Option Explicit On
Option Default None

Dim data$(5) = ("one", "two", "three", "four", "five")

Sort data$(), , , 2, 3

> run "bug.bas"
Error in line 7: 3 is invalid (valid is 0 to 2)


Should sort elements 2, 3 and 4.

Best wishes,

Tom
Edited 2020-11-28 23:22 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8567
Posted: 01:26pm 28 Nov 2020
Copy link to clipboard 
Print this post

  Quote  Hopefully this one is immune to argument:


Please stop wasting my time when you know the workaround. Your attitude on these issues often encourage me to not do things rather than the opposite
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3831
Posted: 01:51pm 28 Nov 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  Hopefully this one is immune to argument:


Please stop wasting my time when you know the workaround. Your attitude on these issues often encourage me to not do things rather than the opposite


What workaround.

Base is 1
Array has 5 elements numbered 1, 2, 3, 4 and 5
Signature of SORT is:
SORT array() [,indexarray] [,flags] [,startposition] [,elementstosort]


I wrote
Sort data$(), , , 2, 3

So startposition = 2, this is a valid start position
elements to sort = 3, so we are sorting 3 elements
Starting at position 2 and counting 3 elements we are thus sorting elements 2, 3, 4

Elements 2, 3, 4 are valid and do not include the last element of the array.

QED the error reported is wrong, this is a bug.

Best wishes,

Tom
Edited 2020-11-28 23:52 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3831
Posted: 02:11pm 28 Nov 2020
Copy link to clipboard 
Print this post

And here's another one for your collection, a case of too eager token replacement:

> list "bug2.bas"
Print "=> =<"

> run "bug2.bas"
>= <=


My apologies for trying to help and report bugs in beta versions of the firmware,

Tom
Edited 2020-11-29 00:12 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
     Page 3 of 3    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024