Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:13 01 Aug 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 : CMM2: Program Access to Editor

Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 05:20pm 07 Jun 2021
Copy link to clipboard 
Print this post

> list
Print "This is a test."
edit "tfile.txt"
Print "The test is over"

> run
This is a test.
Error in line 2: Invalid in a program

>

I suppose it would be asking too much to allow a running program to use the built-in editor. Why would I want that? A current project would benefit from having a built-in editor. Yes, the user could exit my program, run the editor to create and edit her file, then re-run my program to use her file, but that is a royal pain. As it stands, I must implement my own editor with the features I want, or maybe tear XEdit apart to get what I want. Yet the ideal tool is already baked into the firmware...

From the user's perspective, ESC would exit the editor and return to my program and F1, F2 and F6 would just save the file and return to my program. Obviously there would be a lot going on behind the scenes in order to preserve the environment of the running program.

Perhaps the calling program could be re-run from its start when the editor exits back to it, with a mm.info field set to indicate that fact. Then there would be no need to preserve the run environment. Also, the editor would benefit from knowing how it was invoked so that it could adjust the command hint text at the bottom of the screen.

Just some thoughts.
Visit Vegipete's *Mite Library for cool programs.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 05:54pm 07 Jun 2021
Copy link to clipboard 
Print this post

No - sorry. The editor takes over the machine and kills everything the program might want , variables , I/O, timers
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 10:25pm 07 Jun 2021
Copy link to clipboard 
Print this post

Hence the thought that the calling program would be re-run from the start after the editor finishes, with, for example, MM.INFO(WHO_RUN_ME) set to, say, 3.

The non-existent read-only variable MM.INFO(WHO_RUN_ME) returns:
0 - command prompt (Would console/serial port be distinct from USB keyboard)
1 - file manager
2 - editor (via F2)
3 - editor called by this program
4 - chained
5 - run by a different program
6 - ?

Again, just a thought.
Visit Vegipete's *Mite Library for cool programs.
 
NPHighview

Senior Member

Joined: 02/09/2020
Location: United States
Posts: 203
Posted: 04:05pm 08 Jun 2021
Copy link to clipboard 
Print this post

I think what you might want is the ability for MMBASIC to do Anonymous Functions or Lambda Expressions.  This capability is getting to be pretty commonplace these days, in C#, C++, Python, Java, and even JavaScript.  

It might not be quite as interactive as you'd want, but it would permit passing a string to a built-in command interpreter and executing it.  The string could come from user input, or be constructed procedurally by the main program.
Live in the Future. It's Just Starting Now!
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 04:21pm 08 Jun 2021
Copy link to clipboard 
Print this post

The problem in this instance is probably the restricted memory management that's available. You might be able to chain a separate editor, I suppose, getting the name of the file in mm.cmdline$. Just that minor bit about writing one. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4044
Posted: 01:00pm 09 Jun 2021
Copy link to clipboard 
Print this post

  NPHighview said  I think what you might want is the ability for MMBASIC to do Anonymous Functions or Lambda Expressions.  This capability is getting to be pretty commonplace these days, in C#, C++, Python, Java, and even JavaScript.  

It might not be quite as interactive as you'd want, but it would permit passing a string to a built-in command interpreter and executing it.  The string could come from user input, or be constructed procedurally by the main program.

A program can pass such a string to MMBasic but it has some limitations.

I think the main snags include such things as:
1. usually a system has an OS and then one/some language subsystem(s), but MMBasic is both rolled into one
2. the usual kind is BIGGER so would not have fitted into the original chips without reducing yet further the feature set (and there was no need or desire to do it)
3. it's quite a task to re-implement/re-structure MMBasic
4. there may be no volunteers to do it
5. the copyright does not of itself allow any such work to be released to others

John
Edited 2021-06-09 23:00 by JohnS
 
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